Ir al contenido principal

Entradas

Mostrando entradas de enero, 2021

Delete Redis keys matching a pattern

Though Redis allows searching entries based on a key pattern (command KEYS ), it doesn't allow bulk deleting entries based on a key pattern, what can be useful in many scenarios, as that in which you need to refresh part of your cache and don't want to entirely drop it. However, we can do it by using the redis-cli pipe mode, that allows redis-cli executing a list of commands received by the standard input. Let's see how to delete a set of entries based on a key pattern: redis-cli --raw KEYS mykeyprefix* | awk '{print "DEL "$0}' | redis-cli --pipe As can be seen, three commands are used: The first command, redis-cli --raw KEYS mykeyprefix* , executes the Redis command KEYS mykeyprefix* for getting all the keys starting by "mykeyprefix", and sends the raw result to the standard output. awk '{print "DEL "$0}' basically transforms the previous command output by prefixing every line with DEL ,

Useful redis commands (in a nutshell)

redis-cli , the Redis command line tool, is a quick shortcut for running the most common operations that require our everyday job. Let's review them in a nutshell: To open a server session, run the console command: shell> redis-cli -h <hostname> The password can be specified in the above command by setting the -a <password> argument, but for security reasons it's better to authenticate once in the redis-cli console: redis> AUTH [username] password Again from the console, to check if one ore more keys exist: redis> EXISTS <key> [<key> ...] To search keys matching a given pattern: redis> KEYS <pattern> To get an entry value given its key: redis> GET <key> To delete an entry given its key: redis> DEL <key> To quit the redis-cli session: redis> EXIT Lastly, to access to the redis-cli command reference click here .

Linting C# in Visual Studio Code

Though very usual in programming environments as Javascript/Typescript, linting , or analyzing code for enforcing a set of coding style rules, is not usually present in the .NET based environments. Rule enforcing is really useful when working on team shared codebases in order to keep them coherent, what in last term reduces both development times and coding errors. A linting example Maybe a practical example would be helpful for explaining what  linting  is to the newcomers (feel free to go on if you aren't). Let's imagine you are a new member in a C# development team that has well established set of coding style rules. Instead (or apart) of putting them in a document, they've adopted a tool that checks these rules during the code building process. Your first code is such ambitious as this: namespace HelloWorld {      using System;      public class Program      {           public static void Main(string[] args)           {                Console

Update NPM to the latest version (in a nutshell)

To update npm itself to its latest version, run the command: npm install -g npm@latest If working on Linux/Mac, chances are that you need superuser rights, so prefix the above command with sudo : sudo npm install -g npm@latest Finally, to check the version before and after updating, run the command npm -v