question
stringlengths
11
28.2k
answer
stringlengths
26
27.7k
tag
stringclasses
130 values
question_id
int64
935
78.4M
score
int64
10
5.49k
I am using PostgreSQL via the Ruby gem 'sequel'. I'm trying to round to two decimal places. Here's my code: SELECT ROUND(AVG(some_column),2) FROM table I get the following error: PG::Error: ERROR: function round(double precision, integer) does not exist (Sequel::DatabaseError) I get no error when I run the fol...
PostgreSQL does not define round(double precision, integer). For reasons @Mike Sherrill 'Cat Recall' explains in the comments, the version of round that takes a precision is only available for numeric. regress=> SELECT round( float8 '3.1415927', 2 ); ERROR: function round(double precision, integer) does not exist reg...
PostgreSQL
13,113,096
345
How can I list all the tables of a PostgreSQL database and order them by size?
select table_name, pg_size_pretty(pg_total_relation_size(quote_ident(table_name))), pg_total_relation_size(quote_ident(table_name)) from information_schema.tables where table_schema = 'public' order by 3 desc; This shows you the size of all tables in the schema public if you have multiple schemas, you might want...
PostgreSQL
21,738,408
344
I want to run this query: SELECT DISTINCT ON (address_id) purchases.address_id, purchases.* FROM purchases WHERE purchases.product_id = 1 ORDER BY purchases.purchased_at DESC But I get this error: PG::Error: ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY expressions Adding address_id as first ORD...
Documentation says: DISTINCT ON ( expression [, ...] ) keeps only the first row of each set of rows where the given expressions evaluate to equal. [...] Note that the "first row" of each set is unpredictable unless ORDER BY is used to ensure that the desired row appears first. [...] The DISTINCT ON expression(s) must ...
PostgreSQL
9,795,660
343
I would like to give a user all the permissions on a database without making it an admin. The reason why I want to do that is that at the moment DEV and PROD are different DBs on the same cluster so I don't want a user to be able to change production objects but it must be able to change objects on DEV. I tried: grant ...
All commands must be executed while connected to the right database cluster. Make sure of it. Roles are objects of the database cluster. All databases of the same cluster share the set of defined roles. Privileges are granted / revoked per database / schema / table etc. A role needs access to the database, obviously. T...
PostgreSQL
22,483,555
342
Every time I run my rails 4.0 server, I get this output. Started GET "/" for 127.0.0.1 at 2013-11-06 23:56:36 -0500 PG::ConnectionBad - could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection...
It could be as simple as a stale PID file. It could be failing silently because your computer didn't complete the shutdown process completely which means postgres didn't delete the PID (process id) file. The PID file is used by postgres to make sure only one instance of the server is running at a time. So when it goes ...
PostgreSQL
19,828,385
339
I have been facing a strange scenario when comparing dates in postgresql(version 9.2.4 in windows). I have a column in my table say update_date with type timestamp without timezone. Client can search over this field with only date (e.g: 2013-05-03) or date with time (e.g.: 2013-05-03 12:20:00). This column has the val...
@Nicolai is correct about casting and why the condition is false for any data. i guess you prefer the first form because you want to avoid date manipulation on the input string, correct? you don't need to be afraid: SELECT * FROM table WHERE update_date >= '2013-05-03'::date AND update_date < ('2013-05-03'::date + '1...
PostgreSQL
19,469,154
335
I'm doing a web app, and I need to make a branch for some major changes, the thing is, these changes require changes to the database schema, so I'd like to put the entire database under git as well. How do I do that? is there a specific folder that I can keep under a git repository? How do I know which one? How can I b...
Take a database dump, and version control that instead. This way it is a flat text file. Personally I suggest that you keep both a data dump, and a schema dump. This way using diff it becomes fairly easy to see what changed in the schema from revision to revision. If you are making big changes, you should have a second...
PostgreSQL
846,659
332
I ran following sql script on my database: create table cities ( id serial primary key, name text not null ); create table reports ( id serial primary key, cityid integer not null references cities(id), reportdate date not null, reporttext text not null ); create user www with password 'www'; grant select on cities ...
Since PostgreSQL 8.2 you have to use: GRANT USAGE, SELECT ON SEQUENCE cities_id_seq TO www; GRANT USAGE - For sequences, this privilege allows the use of the currval and nextval functions. Also as pointed out by @epic_fil in the comments you can grant permissions to all the sequences in the schema with: GRANT USAGE, S...
PostgreSQL
9,325,017
331
I'm building a Django site and I am looking for a search engine. A few candidates: Lucene/Lucene with Compass/Solr Sphinx Postgresql built-in full text search MySQl built-in full text search Selection criteria: result relevance and ranking searching and indexing speed ease of use and ease of integration with Django ...
Good to see someone's chimed in about Lucene - because I've no idea about that. Sphinx, on the other hand, I know quite well, so let's see if I can be of some help. Result relevance ranking is the default. You can set up your own sorting should you wish, and give specific fields higher weightings. Indexing speed is su...
PostgreSQL
737,275
329
What is best way to check if value is null or empty string in Postgres sql statements? Value can be long expression so it is preferable that it is written only once in check. Currently I'm using: coalesce( trim(stringexpression),'')='' But it looks a bit ugly. stringexpression may be char(n) column or expression conta...
The expression stringexpression = '' yields: true   .. for '' (or for any string consisting of only spaces with the data type char(n)) null   .. for null false .. for anything else "stringexpression is either null or empty" To check for this, use: (stringexpression = '') IS NOT FALSE Or the reverse approach (may be e...
PostgreSQL
23,766,084
329
Is there a way using SQL to list all foreign keys for a given table? I know the table name / schema and I can plug that in.
You can do this via the information_schema tables. For example: SELECT tc.table_schema, tc.constraint_name, tc.table_name, kcu.column_name, ccu.table_schema AS foreign_table_schema, ccu.table_name AS foreign_table_name, ccu.column_name AS foreign_column_name FROM information_schema.tabl...
PostgreSQL
1,152,260
329
Since PostgreSQL came out with the ability to do LATERAL joins, I've been reading up on it since I currently do complex data dumps for my team with lots of inefficient subqueries that make the overall query take four minutes or more. I understand that LATERAL joins may be able to help me, but even after reading article...
What is a LATERAL join? The feature was introduced with PostgreSQL 9.3. The manual: Subqueries appearing in FROM can be preceded by the key word LATERAL. This allows them to reference columns provided by preceding FROM items. (Without LATERAL, each subquery is evaluated independently and so cannot cross-reference any ...
PostgreSQL
28,550,679
324
I have a Postgresql database on which I want to do a few cascading deletes. However, the tables aren't set up with the ON DELETE CASCADE rule. Is there any way I can perform a delete and tell Postgresql to cascade it just this once? Something equivalent to DELETE FROM some_table CASCADE; The answers to this older q...
No. To do it just once you would simply write the delete statement for the table you want to cascade. DELETE FROM some_child_table WHERE some_fk_field IN (SELECT some_id FROM some_Table); DELETE FROM some_table;
PostgreSQL
129,265
322
I'm trying to remove a key from a RethinkDB document. My approaches (which didn't work): r.db('db').table('user').replace(function(row){delete row["key"]; return row}) Other approach: r.db('db').table('user').update({key: null}) This one just sets row.key = null (which looks reasonable). Examples tested on rethinkd...
Here's the relevant example from the documentation on RethinkDB's website: http://rethinkdb.com/docs/cookbook/python/#removing-a-field-from-a-document To remove a field from all documents in a table, you need to use replace to update the document to not include the desired field (using without): r.db('db').table('user'...
RethinkDB
18,580,397
47
I'm developing an application that works distributed, and I have a SQLite database that must be shared between distributed servers. If I'm in serverA, and change sqlite row, this change must be in the other servers instantly, but if a server were offline and then it came online, it must update all info equal other serv...
I used the Raft consensus protocol to replicate my SQLite database. You can find the system here: https://github.com/rqlite/rqlite
RethinkDB
16,032,825
45
This is my official first question here; I welcome any/all criticism of my post so that I can learn how to be a better SO citizen. I am vetting non-relational DBMS for storing potentially large email opt-out lists, leaning toward either MongoDB or RethinkDB, using their respective Python client libraries. The pain poi...
RethinkDB currently implements batch inserts by doing a single insert at a time on the server. Since Rethink flushes every record to disk (because it's designed with safety first in mind), this has a really bad effect on workloads like this one. We're doing two things to address this: Bulk inserts will be implemented ...
RethinkDB
15,151,554
25
One way I know I can do it is by listing throughdbList() and tableList() and then looking for what I want in the results. Is there an easier way? EDIT My goal is to create a table in case it doesn't exist.
If you want to create a database if it does not exists, or get a value like "database already exists" if it does exist, you could do something like the following: r.dbList().contains('example_database') .do(function(databaseExists) { return r.branch( databaseExists, { dbs_created: 0 }, r.dbCreat...
RethinkDB
31,625,913
24
I have this object: { "id": "eb533cd0-fef1-48bf-9fb8-b66261c9171b" , "errors": [ "error1" , "error2" ] } I simply want to append a new error to errors array. I tried: r.db('test').table('taskQueue').get("eb533cd0-fef1-48bf-9fb8-b66261c9171b").update({'errors': r.row['errors'].append('append...
r.db('test').table('taskQueue').get("eb533cd0-fef1-48bf-9fb8-b66261c9171b").update({ errors: r.row('errors').append('appended error') }) So not r.row['errors'], but r.row('errors').
RethinkDB
22,846,614
19
Currently I'm using socket.io without RethinkDB like this: Clients emit events to socket.io, which receives the events, emits to various other clients, and saves to the db for persistence. A new client connecting will get existing data from the db then listen to new events over socket.io. How would switching to Rethink...
First, let's clarify the relationship between socket.io and RethinkDB changefeeds. Socket.io is intended for realtime communication between client (the browser) and the server (Node.js). RethinkDB changfeeds are way for your server (Node.js) to listen to changes in the database. The client can't communicate with Rethin...
RethinkDB
30,527,698
19
Having just arrived to Elixir/Phoenix I want to use RethinkDB instead of PostgreSQL but I only find documentation/examples on PostgreSQL (which seems to be the default/official database). There is a very good package from Hamiltop (Rethinkdb-elixir) but unfortunately the documentation in the Wiki is not ready and in th...
Step 1) Generate project without ecto: mix phoenix.new some_app --no-ecto Step 2) Add rethinkdb as a dependency in mix.exs defp deps do [{:phoenix, "~> 0.13.1"}, {:phoenix_html, "~> 1.0"}, {:phoenix_live_reload, "~> 0.4", only: :dev}, {:rethinkdb, "~> 0.0.5"}, {:cowboy, "~> 1.0"}] end Step 3) Run mix de...
RethinkDB
31,457,945
18
How to create unique items in RethinkDB? In MongoDb I used ensureIndex for this, eg: userCollection.ensureIndex({email:1},{unique:true},function(err, indexName){
RethinkDB does not currently support uniqueness constraints on fields other than the primary key. You could use an auxiliary table where the unique field is stored as the primary key in order to check for uniqueness in your application explicitly.
RethinkDB
17,789,123
17
I am building an application with RethinkDB and I'm about to switch to using changefeeds. But I'm facing an architectural choice and I'd like to get some advice. My application currently loads all user data from several tables on user login (sending all of it to the frontend), and then processes requests from the front...
RethinkDB should be able to handle thousands of changefeeds just fine if it's on reasonable hardware. One thing some people to do lower network load in that case is they put a proxy node on the same machine as their app server, and connect to that, since the proxy node knows enough to deduplicate the changefeed messag...
RethinkDB
37,510,529
13
How to make a rethinkdb atomic update if document exists, insert otherwise? I want to do something like: var tab = r.db('agflow').table('test'); r.expr([{id: 1, n: 0, x: 11}, {id: 2, n: 0, x: 12}]).forEach(function(row){ var _id = row('id'); return r.branch( tab.get(_id).eq(null), // 1 tab.insert(row), ...
I think the solution is passing conflict="update" to the insert method. Als see RethinkDB documentation on insert
RethinkDB
24,306,933
12
On the api documentation page rethinkdb.com/api/javascript I can only find commands to create, drop and list databases. But how I can I rename a database in RethinkDB?
You basically have two options: 1. Update the name using the .config method You can also update the name using the .config method every database and tables has. This would look something like this: r .db("db_name") .config() .update({name: "new_db_name"}) 2. Update the db_config table You can also execute a quer...
RethinkDB
29,378,739
12
I am starting with a simple TODO app with Aurelia, RethinkDB & Socket.IO. I seem to have problem with re-rendering or re-evaluating an object that is changed through Socket.IO. So basically, everything works good on the first browser but doesn't get re-rendered in the second browser while displaying the object in the c...
Aurelia observes changes to the contents of an array by overriding the array's mutator methods (push, pop, splice, shift, etc). This works well for most use-cases and performs really well (no dirty-checking, extremely lightweight in terms of memory and cpu). Unfortunately this leaves one way of mutating an array that...
RethinkDB
36,394,399
12
I am building the back-end for my web app; it would act as an API for the front-end and it will be written in Python (Flask, to be precise). After taking some decisions regarding design and implementation, I got to the database part. And I started thinking whether NoSQL data storage may be more appropriate for my proje...
I'm working at RethinkDB, but that's my unbiased answer as a web developer (at least as unbiased as I can). Flexible schema are nice from a developer point of view (and in your case). Like you said, with something like PostgreSQL you would have to format all the data you pull from third parties (SoundCloud, Facebook e...
RethinkDB
20,597,590
11
I am using testdouble for stubbing calls within my node.js project. This particular function is wrapping a promise and has multiple then calls within the function itself. function getUser (rethink, username) { return new Promise((resolve, reject) => { let r = database.connect(); r.then(conn => database.table(tab...
So figured out the resolution. There are a few things to note in the solution and that we encountered. In short the resolution ended up being this... td.when(database.connect()).thenResolve({then: (resolve) => resolve('ok')}); This resolves a thenable that is returned when test double sees database connect. Then subse...
RethinkDB
42,935,880
11
Attempting to use this example to join on an array of IDs: https://github.com/rethinkdb/rethinkdb/issues/1533#issuecomment-26112118 Stores table snippet { "storeID": "80362c86-94cc-4be3-b2b0-2607901804dd", "locations": [ "5fa96762-f0a9-41f2-a6c1-1335185f193d", "80362c86-94cc-4be3-b2b0-2607901804dd" ] } ...
You're using concatMap incorrectly, here's what you want the first part of your query to be. r.table("stores") .concatMap(function (x) { return x("locations"); }) Try running that, it should give you: ["5fa96762-...", "80362c86-...", ...] Now we need to join this to the other table. To join an array of ids to a ...
RethinkDB
20,909,723
10
I'm trying to write the most optimal query to find all of the documents that do not have a specific field. Is there any better way to do this than the examples I have listed below? // Get the ids of all documents missing "location" r.db("mydb").table("mytable").filter({location: null},{default: true}).pluck("id") // G...
A naive suggestion You could use the hasFields method along with the not method on to filter out unwanted documents: r.db("mydb").table("mytable") .filter(function (row) { return row.hasFields({ location: true }).not() }) This might or might not be faster, but it's worth trying. Using a secondary index Ideall...
RethinkDB
29,724,041
10
I want to run a function that iterates through a generator class. The generator functions would run as long as the Ratchet connection is alive. All I need to do is to make this happen after the run method is executed: use Ratchet\Server\IoServer; use Ratchet\Http\HttpServer; use Ratchet\WebSocket\WsServer; use MyApp\Ch...
Let's start by example: <?php require 'vendor/autoload.php'; class Chat implements \Ratchet\MessageComponentInterface { function onOpen(\Ratchet\ConnectionInterface $conn) { echo "connected.\n"; } function onClose(\Ratchet\ConnectionInterface $conn) {} function onError(\Ratchet\ConnectionInterface $conn, ...
RethinkDB
49,338,015
10
The DynamoDB Wikipedia article says that DynamoDB is a "key-value" database. However, calling it a "key-value" database completely misses an extremely fundamental feature of DynamoDB, that of the sort key: Keys have two parts (partition key and sort key) and items with the same partition key can be efficiently retrieve...
Before CQL was introduced, Cassandra adhered more strictly the wide column store data model, where you only had rows identified by a row key and containing sorted key/value columns. With the introduction of CQL, rows became known as partitions and columns could optionally be grouped in to logical rows via clustering k...
Scylla
60,798,118
15
I have a table with a column of type list and I would like to check if there is an item inside the list, using CONTAINS keyword. According to scylla documentation: The CONTAINS operator may only be used on collection columns (lists, sets, and maps). In the case of maps, CONTAINS applies to the map values. The CONTAINS...
Support for CONTAINS keyword for filtering is already implemented in Scylla, but it's not part of any official release yet - it will be included in the upcoming 3.1 release (or, naturally, if you build it yourself from the newest source). Here's the reference from the official tracker: https://github.com/scylladb/scyll...
Scylla
57,874,319
11
I am new to Docker, and trying to go through this tutorial setting up MemSQL from a Docker image - http://docs.memsql.com/4.0/setup/docker/ . I am on a Mac, and the tutorial uses boot2docker which seems to have been deprecated. The VM needs 4GB memory to run. The tutorial specifies how to do this with boot2docker b...
You can do this via the command line. For example, to change the machine from the default 1cpu/2048MB RAM run: docker-machine stop VBoxManage modifyvm default --cpus 2 VBoxManage modifyvm default --memory 4096 docker-machine start You can then check your settings: VBoxManage showvminfo default | grep Memory VBoxManage...
SingleStore
32,834,082
122
I realize other people have had similar questions but this uses v2 compose file format and I didn't find anything for that. I want to make a very simple test app to play around with MemSQL but I can't get volumes to not get deleted after docker-compose down. If I've understood Docker Docs right, volumes shouldn't be de...
I realize this is an old and solved thread where the OP was pointing to a directory in the container rather than the volume they had mounted, but wanted to clear up some of the misinformation I'm seeing. docker-compose down does not remove volumes, you need to run docker-compose down -v if you also want to delete volum...
SingleStore
35,620,997
26
MemSQL is claiming to be the "Worlds Fastest Database" Faster than DB2, Oracle, mySQL and SQL server. Can anyone vouch for this? I have searched the web and tried to gather as much information as possible about this. MemSQL is claiming to be the fastest database on the planet. Faster than Oracle, DB2, MySQL and MS SQL....
The MemSQL lacks community support, we have no information about the enterprise license (there is available a version for more than 32GB) and maybe there is no proof of speed for your application yet. However you have to try it. Really. The performance for static queries and prepared statements are promising, the best ...
SingleStore
13,892,907
20
Using Spark 1.4.0, I am trying to insert data from a Spark DataFrame into a MemSQL database (which should be exactly like interacting with a MySQL database) using insertIntoJdbc(). However I keep getting a Runtime TableAlreadyExists exception. First I create the MemSQL table like this: CREATE TABLE IF NOT EXISTS table...
This solution applies to general JDBC connections, although the answer by @wayne is probably a better solution for memSQL specifically. insertIntoJdbc seems to have been deprecated as of 1.4.0, and using it actually calls write.jdbc(). write() returns a DataFrameWriter object. If you want to append data to your ta...
SingleStore
32,915,682
12
According to this SQL join cheat-sheet, a left outer join on one column is the following : SELECT * FROM a LEFT JOIN b ON a.foo = b.foo WHERE b.foo IS NULL I'm wondering what it would look like with a join on multiple columns, should it be an OR or an AND in the WHERE clause ? SELECT * FROM a LEFT JOI...
That depends on whether the columns are nullable, but assuming they are not, checking any of them will do: SELECT * FROM a LEFT JOIN b ON a.foo = b.foo AND a.bar = b.bar AND a.ter = b.ter WHERE b.foo IS NULL -- this could also be bar or ter This is because after a successful join, all three columns w...
Vertica
40,015,779
19
Is there any way I can store the last iterated row result and use that for next row iteration? For example I have a table say(Time_Table). __ Key type timeStamp 1 ) 1 B 2015-06-28 09:00:00 2 ) 1 B 2015-06-28 10:00:00 3 ) 1 C 2015-06-28 11:00:00 4 ) 1 A 20...
This is not possible using just pure SQL in Vertica. To do this in pure SQL you need to be able to perform a recursive query which is not supported in the Vertica product. In other database products you can do this using a WITH clause. For Vertica you are going to have to do it in the application logic. This is bas...
Vertica
37,020,449
15
I'm using the following: DRIVER={Vertica ODBC Driver 4.1}; SERVER=lnxtabdb01.xxxx.com; PORT=5433; DATABASE=vertica; USER=dbadmin; PASSWORD=vertica; OPTION=3; i'm getting this error and I just wanted to make sure that my connection string was cool before I check other possible issues. error: EnvironmentError: System.Da...
The accepted answer describes a way to connect with the Vertica ODBC driver using a System DSN. It is possible to connect using just a connection string to directly configure the connection against the driver. The following connection string pattern has been tested against the Vertica ODBC Client Driver v6.1.2: Driver=...
Vertica
5,807,510
10
Hi I have configured the DSN settings for vertica in Ubuntu 10.10 32 bit version machine. The settings are all fine and I have cross checked them. Here is my odbc.ini file: [VerticaDSN] Description = VerticaDSN ODBC driver Driver = /opt/vertica/lib/libverticaodbc_unixodbc.so Servername = myservername Database...
You may be missing the Driver configuration section. Edit or create the file /etc/vertica.ini with the following content: [Driver] DriverManagerEncoding=UTF-16 ODBCInstLib=/usr/lib64/libodbcinst.so ErrorMessagesPath=/opt/vertica/lib64 LogLevel=4 LogPath=/tmp More information can be found in the Vertica Programmer's Gu...
Vertica
9,778,033
10
Anyone know of a handy function to search through column_names in Vertica? From the documentation, it seems like \d only queries table_names. I'm looking for something like MySQL's information_schema.columns, but can't find any information about a similar table of meta-data. Thanks!
In 5.1 if you have enough permissions you can do SELECT * FROM v_catalog.columns; to access columns's info, for some things you'll need to join with v_catalog.tables
Vertica
10,047,469
10
I read about Voltdb's command log. The command log records the transaction invocations instead of each row change as in a write-ahead log. By recording only the invocation, the command logs are kept to a bare minimum, limiting the impact the disk I/O will have on performance. Can anyone explain the database theory behi...
I think it is better to rephrase: Why does new distributed VoltDB use a command log over write-ahead log? Let's do an experiment and imagine you are going to write your own storage/database implementation. Undoubtedly you are advanced enough to abstract a file system and use block storage along with some additional...
VoltDB
14,181,180
59
I am quite new for zookeeper port through which I am coming across from past few days. I introduced with zookeeper port keyword at two occasion: while configuring neo4j db cluster (link) and while running compiled voltdb catalog (link) (See Network Configuration Arguments) Then, I came across Apache Zookeeper, (which...
Zookeeper is used in distributed applications mainly for configuration management and high availability operations. Zookeeper does this by a Master-Slave architecture. Neo4j and VoltDb might be using zookeeper for this purpose Coming to the ports understanding : suppose u have 3 servers for zookeepers ... You need to m...
VoltDB
18,168,541
27
I've been working on a project for over half a year now, building healthcare software from the ground up. When I joined up, MySQL had been chosen as the primary data store. A few months and many headaches later, we've begun to investigate alternative data stores that can offer the flexibility we need to record our crit...
We went live last year with an application that uses VoltDB. We're storing around 1.5 billion records and processing 50-90 million transactions a day with a kfactor=1 4 server cluster ( 256 GB memory/server ). Given the performance of VoltDB, we could easily be handing 1 billion transactions a day. To date, we have had...
VoltDB
9,285,335
13
We're using a Ruby web-app with Redis server for caching. Is there a point to test Memcached instead? What will give us better performance? Any pros or cons between Redis and Memcached? Points to consider: Read/write speed. Memory usage. Disk I/O dumping. Scaling.
Summary (TL;DR) Updated June 3rd, 2017 Redis is more powerful, more popular, and better supported than memcached. Memcached can only do a small fraction of the things Redis can do. Redis is better even where their features overlap. For anything new, use Redis. Memcached vs Redis: Direct Comparison Both tools are powerf...
Redis
10,558,465
1,482
I want to delete all keys. I want everything wiped out and give me a blank database. Is there a way to do this in Redis client?
With redis-cli: FLUSHDB – Deletes all keys from the connection's current database. FLUSHALL – Deletes all keys from all databases on current host. For example, in your shell: redis-cli flushall
Redis
6,851,909
931
In my Redis DB I have a number of prefix:<numeric_id> hashes. Sometimes I want to purge them all automatically. How do I do this without using some distributed locking mechanism?
Execute in bash: redis-cli KEYS "prefix:*" | xargs redis-cli DEL UPDATE Ok, i understood. What about this way: store current additional incremental prefix and add it to all your keys. For example: You have values like this: prefix_prefix_actuall = 2 prefix:2:1 = 4 prefix:2:2 = 10 When you need to purge data, you chan...
Redis
4,006,324
791
Is there a Redis command for fetching all keys in the database? I have seen some python-redis libraries fetching them. But was wondering if it is possible from redis-client.
Try to look at KEYS command. KEYS * will list all keys stored in redis. EDIT: please note the warning at the top of KEYS documentation page: Time complexity: O(N) with N being the number of keys in the database, under the assumption that the key names in the database and the given pattern have limited length. UPDATE ...
Redis
5,252,099
734
During writes to Redis ( SET foo bar ) I am getting the following error: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. Basically I understand that the problem...
Restart your redis server. macOS (brew): brew services restart redis. Linux: sudo service redis restart / sudo systemctl restart redis Windows: Windows + R -> Type services.msc, Enter -> Search for Redis then click on restart. I had this issue after upgrading redis with Brew (brew upgrade). Once I restarted my laptop...
Redis
19,581,059
677
I apparently have a redis-server instance running because when I try to start a new server by entering redis-server, I'm greeted with the following: Opening port: bind: Address already in use I can't figure out how to stop this server and start a new one. Is there any command I can append to redis-server when I'm typi...
Either connect to node instance and use shutdown command or if you are on ubuntu you can try to restart redis server through init.d: /etc/init.d/redis-server restart or stop/start it: /etc/init.d/redis-server stop /etc/init.d/redis-server start On Mac redis-cli shutdown
Redis
6,910,378
544
I am a learner in Node.js. What's Express.js? What's the purpose of it with Node.js? Why do we actually need Express.js? How is it useful for us to use with Node.js? What's Redis? Does it come with Express.js?
1) What is Express.js? Express.js is a Node.js framework. It's the most popular framework as of now (the most starred on NPM). . It's built around configuration and granular simplicity of Connect middleware. Some people compare Express.js to Ruby Sinatra vs. the bulky and opinionated Ruby on Rails. 2) What is the p...
Redis
12,616,153
504
What I want is not a comparison between Redis and MongoDB. I know they are different; the performance and the API is totally different. Redis is very fast, but the API is very 'atomic'. MongoDB will eat more resources, but the API is very very easy to use, and I am very happy with it. They're both awesome, and I want t...
I would say, it depends on kind of dev team you are and your application needs. For example, if you require a lot of querying, that mostly means it would be more work for your developers to use Redis, where your data might be stored in variety of specialized data structures, customized for each type of object for effic...
Redis
5,400,163
466
I want to store a JSON payload into redis. There's really 2 ways I can do this: One using a simple string keys and values. key:user, value:payload (the entire JSON blob which can be 100-200 KB) SET user:1 payload Using hashes HSET user:1 username "someone" HSET user:1 location "NY" HSET user:1 bio "STRING WITH OVER 10...
This article can provide a lot of insight here: http://redis.io/topics/memory-optimization There are many ways to store an array of Objects in Redis (spoiler: I like option 1 for most use cases): Store the entire object as JSON-encoded string in a single key and keep track of all Objects using a set (or list, if more ...
Redis
16,375,188
359
I'm trying to answer two questions in a definitive list: What are the underlying data structures used for Redis? And what are the main advantages/disadvantages/use cases for each type? So, I've read the Redis lists are actually implemented with linked lists. But for other types, I'm not able to dig up any information...
I'll try to answer your question, but I'll start with something that may look strange at first: if you are not interested in Redis internals you should not care about how data types are implemented internally. This is for a simple reason: for every Redis operation you'll find the time complexity in the documentation an...
Redis
9,625,246
349
Hi I am using Laravel with Redis .When I am trying to access a key by get method then get following error "WRONGTYPE Operation against a key holding the wrong kind of value" I am using following code to access the key value - i use this code for get data from redis $values = "l_messages"; $value = $redis->HGETALL($val...
Redis supports 6 data types. You need to know what type of value that a key maps to, as for each data type, the command to retrieve it is different. Here are the commands to retrieve key value(s): if value is of type string -> GET <key> if value is of type hash -> HGET or HMGET or HGETALL <key> if value is of type lis...
Redis
37,953,019
346
I have a Linux server with Redis installed and I want to connect to it via command line from my local Linux machine. Is it possible to install redis-cli only (without redis-server and other tools)? If I just copy redis-cli file to my local machine and run it, I have the following error: ./redis-cli: /lib/x86_64-linux-g...
Ubuntu (tested on 14.04) has package called redis-tools which contains redis-cli among other tools. To install it type: sudo apt-get install redis-tools Note that on Ubuntu 16.04+ the command is a little bit different: sudo apt install redis-tools
Redis
21,795,340
313
I'm trying to follow the Redis installation process that was discuss in this article of digital ocean, for in WSL(Windows Sub-System for Linux). The Ubuntu version installed is Ubuntu 18.04. Everything in redis installation is fine but when I tried to run this sudo systemctl start redis I got this message. System has n...
Instead, use: sudo service redis-server start I had the same problem, stopping/starting other services from within Ubuntu on WSL. This worked, where systemctl did not. And one could reasonably wonder, "how would you know that the service name was 'redis-server'?" You can see them using service --status-all
Redis
52,197,246
310
What is the standard naming convention for keys in redis? I've seen values separated by :, but I'm not sure what the standard convention is. For a user, would you do something like:user:00 If the user's id was 00 Are you able to query for just the beginning of the key to return all users? I'm mainly just hoping to avoi...
What are the normal naming convention for keys in redis? I've seen values separated by : but I'm not sure what the normal convention is, or why. Yes, colon sign : is a convention when naming keys. In this tutorial on redis website is stated: Try to stick with a schema. For instance "object-type:id:field" can be a nic...
Redis
6,965,451
290
I can't see any difference between Redis and caching technologies like Velocity or the Enterprise Library Caching Framework. You're effectively just adding objects to an in-memory data store using a unique key. There do not seem to be any relational semantics... What am I missing?
No, Redis is much more than a cache. Like a cache, Redis stores key-value pairs. But unlike a cache, Redis lets you operate on the values. There are 5 data types in Redis - Strings, Sets, Hashs, Lists and Sorted Sets. Each data type exposes various operations. The best way to understand Redis is to model an application...
Redis
10,137,857
287
Using homebrew to install Redis but when I try to ping Redis it shows this error: Could not connect to Redis at 127.0.0.1:6379: Connection refused Note : I tried to turn off firewall and edit conf file but still cannot ping. I am using macOS Sierra and homebrew version 1.1.11
After installing redis, type from terminal: redis-server And Redis-Server will be started
Redis
42,857,551
284
how to check Redis server version? I've found in Redis site this command: $ redis-server and that should give me (according to the site): [28550] 01 Aug 19:29:28 # Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf' [28550] 01 Aug 19:29...
$ redis-server --version gives you the version.
Redis
21,555,942
283
I ran this command to access my redis server. telnet 127.0.0.1 6379 What is the command to show all of my databases?
There is no command to do it (like you would do it with MySQL for instance). The number of Redis databases is fixed, and set in the configuration file. By default, you have 16 databases. Each database is identified by a number (not a name). You can use the following command to know the number of databases: CONFIG GET d...
Redis
12,802,726
280
I have URL and PORT of remote Redis server. I am able to write into Redis from Scala. However I want to connect to remote Redis via terminal using redis-server or something similar in order to make several call of hget, get, etc. (I can do it with my locally installed Redis without any problem).
redis-cli -h XXX.XXX.XXX.XXX -p YYYY xxx.xxx.xxx.xxx is the IP address and yyyy is the port EXAMPLE from my dev environment redis-cli -h 10.144.62.3 -p 30000 REDIS CLI COMMANDS Host, port, password and database By default redis-cli connects to the server at 127.0.0.1 port 6379. As you can guess, you can easily chang...
Redis
40,678,865
277
So, I've come to a place where I wanted to segment the data I store in redis into separate databases as I sometimes need to make use of the keys command on one specific kind of data, and wanted to separate it to make that faster. If I segment into multiple databases, everything is still single threaded, and I still onl...
You don't want to use multiple databases in a single redis instance. As you noted, multiple instances lets you take advantage of multiple cores. If you use database selection you will have to refactor when upgrading. Monitoring and managing multiple instances is not difficult nor painful. Indeed, you would get far bett...
Redis
16,221,563
268
I am new to message brokers like RabbitMQ which we can use to create tasks / message queues for a scheduling system like Celery. Now, here is the question: I can create a table in PostgreSQL which can be appended with new tasks and consumed by the consumer program like Celery. Why on earth would I want to setup a whol...
Rabbit's queues reside in memory and will therefore be much faster than implementing this in a database. A (good)dedicated message queue should also provide essential queuing related features such as throttling/flow control, and the ability to choose different routing algorithms, to name a couple(rabbit provides these ...
Redis
13,005,410
268
Is there a way to print the number of keys in Redis? I am aware of keys * But that seems slightly heavy weight. - Given that Redis is a key value store maybe this is the only way to do it. But I would still like to see something along the lines of count keys *
You can issue the INFO command, which returns information and statistics about the server. See here for an example output. As mentioned in the comments by mVChr, you can use info keyspace directly on the redis-cli. redis> INFO # Server redis_version:6.0.6 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:b635753...
Redis
9,888,387
243
Trying to grasp some basics of Redis I came across an interesting blog post . The author states: Redis is single-threaded with epoll/kqueue and scale indefinitely in terms of I/O concurrency. I surely misunderstand the whole threading thing, because I find this statement puzzling. If a program is single-threaded, ho...
Well it depends on how you define concurrency. In server-side software, concurrency and parallelism are often considered as different concepts. In a server, supporting concurrent I/Os means the server is able to serve several clients by executing several flows corresponding to those clients with only one computation un...
Redis
10,489,298
242
I currently have a live redis server running on a cloud instance and I want to migrate this redis server to a new cloud instance and use that instance as my new redis server. If it were MySQL, I would export the DB from the old server and import it into the new server. How should I do this with redis? P.S.: I'm not lo...
First, create a dump on server A. A$ redis-cli 127.0.0.1:6379> CONFIG GET dir 1) "dir" 2) "/var/lib/redis/" 127.0.0.1:6379> SAVE OK This ensures dump.rdb is completely up-to-date, and shows us where it is stored (/var/lib/redis/dump.rdb in this case). dump.rdb is also periodically written to disk automatically. Next, ...
Redis
6,004,915
234
I have not used Redis yet, but I have heard about it and plan to try using it for caching data. I have heard that Redis uses memory as a cache store database. What's the point of Redis, since I can use an object or dictionary to store data? Like this: var cache = { key: { }, key: { } ... }...
Redis is a remote data structure server. It is certainly slower than just storing the data in local memory (since it involves socket roundtrips to fetch/store the data). However, it also brings some interesting properties: Redis can be accessed by all the processes of your applications, possibly running on several nod...
Redis
19,477,821
222
I have read great things about key/value stores such as Redis but I can't seem to figure out when it's time to use it in an application. Say I am architecting a web-based application; I know what stack I am going to use for the front-end, back-end, database(s), etc..what are some scenarios where I would go "oh we also ...
I can't seem to figure out when it's time to use it in an application. I would recommend you to read this tutorial which contains also use cases. Since Redis is rather memory oriented it's really good for frequently updated real-time data, such as session store, state database, statistics, caching and its advanced da...
Redis
7,535,184
220
It's widely mentioned that Redis is "Blazing Fast" and mongoDB is fast too. But, I'm having trouble finding actual numbers comparing the results of the two. Given similar configurations, features and operations (and maybe showing how the factor changes with different configurations and operations), etc, is Redis 10x fa...
Rough results from the following benchmark: 2x write, 3x read. Here's a simple benchmark in python you can adapt to your purposes, I was looking at how well each would perform simply setting/retrieving values: #!/usr/bin/env python2.7 import sys, time from pymongo import Connection import redis # connect to redis & mo...
Redis
5,252,577
220
I've been playing with redis (and add some fun with it) during the last fews days and I'd like to know if there is a way to empty the db (remove the sets, the existing key....) easily. During my tests, I created several sets with a lot of members, even created sets that I do not remember the name (how can I list those ...
You have two options: FLUSHDB - clears currently active database FLUSHALL - clears all the existing databases
Redis
5,756,067
203
I have worked quite a bit with memcached the last weeks and just found out about Redis. When I read this part of their readme, I suddenly got a warm, cozy feeling in my stomach: Redis can be used as a memcached on steroids because is as fast as memcached but with a number of features more. Like memcached, Redis ...
Depends on what you need, in general I think that: You should not care too much about performances. Redis is faster per core with small values, but memcached is able to use multiple cores with a single executable and TCP port without help from the client. Also memcached is faster with big values in the order of 100k. ...
Redis
2,873,249
193
I tried to run brew install redis-cli and googled, but found nothing. Any ideas?
If you install redis with homebrew, you can see what's in the package like this: brew install redis brew ls redis You will see that it only installs very few files indeed anyway: /usr/local/Cellar/redis/3.2.3/bin/redis-benchmark /usr/local/Cellar/redis/3.2.3/bin/redis-check-aof /usr/local/Cellar/redis/3.2.3/bin/redis-...
Redis
39,704,273
187
I understand redis sentinel is a way of configuring HA (high availability) among multiple redis instances. As I see, there is one redis instance actively serving the client requests at any given time. There are two additional servers are on standby (waiting for a failure to happen, so one of them can be in action again...
First, lets talk sentinel. Sentinel manages the failover, it doesn't configure Redis for HA. It is an important distinction. Second, the diagram you posted is actually a bad setup - you don't want to run Sentinel on the same node as the Redis nodes it is managing. When you lose that host you lose both. As to "Is it was...
Redis
31,143,072
180
I can ping pong Redis on the server: # redis-cli ping PONG But remotely, I got problems: $ src/redis-cli -h REMOTE.IP ping Could not connect to Redis at REMOTE.IP:6379: Connection refused In config, I got the standard port: # Accept connections on the specified port, default is 6379. # If port 0 is specified Redis w...
Did you set the bind option to allow remote access on the redis server? Before (file /etc/redis/redis.conf) bind 127.0.0.1 After bind 0.0.0.0 and run sudo service redis-server restart to restart the server. If that's not the problem, you might want to check any firewalls that might block the access. Important: If you...
Redis
19,091,087
173
I'm working with redis on my local machine so I dont really need to set up a password to connect to the server with my php client (I'm using predis as a client). However, I'm moving my app to a live server, so I want to set up a password to connect to my redis server. I have few questions: I checked all over the inte...
To set the password, edit your redis.conf file, find this line # requirepass foobared Then uncomment it and change foobared to your password. Make sure you choose something pretty long, 32 characters or so would probably be good, it's easy for an outside user to guess upwards of 150k passwords a second, as the notes...
Redis
7,537,905
171
I want to use redis-py for caching some data, but I can't find a suitable explanation of the difference between redis.StrictRedis() and redis.Redis(). Are they equivalent? In addition, I can't find any clear documentation about redis.StrictRedis()'s arguments in Redis Python Docs. Any idea?
EDIT: They are now equivalent: redis-py 3.0 drops support for the legacy "Redis" client class. "StrictRedis" has been renamed to "Redis" and an alias named "StrictRedis" is provided so that users previously using "StrictRedis" can continue to run unchanged. Original answer: This seems pretty clear: redis-py exposes ...
Redis
19,021,765
168
I like to use verbose names in Redis, for instance set-allBooksBelongToUser:$userId. Is this ok or does that impact performance?
The key you're talking about using isn't really all that long. The example key you give is for a set, set lookup methods are O(1). The more complex operations on a set (SDIFF, SUNION, SINTER) are O(N). Chances are that populating $userId was a more expensive operation than using a longer key. Redis comes with a b...
Redis
6,320,739
166
Is it currently only possible to expire an entire key/value pair? What if I want to add values to a List type structure and have them get auto removed 1 hour after insertion. Is that currently possible, or would it require running a cron job to do the purging manually?
There is a common pattern that solves this problem quite well. Use sorted sets, and use a timestamp as the score. It's then trivial to delete items by score range, which could be done periodically, or only on every write, with reads always ignoring the out of range elements, by reading only a range of scores. More here...
Redis
7,577,923
163
I have a very small data saved in Redis and the following is working as expected that will allow me to download all keys. redis-cli keys * Is there any way to get the keys+values *?
There's no command for that, but you can write a script to do so. You will need to perform for each key a "type" command: > type <key> and depending on the response perform: for "string": get <key> for "hash": hgetall <key> for "list": lrange <key> 0 -1 for "set": smembers <key> for "zset": zrange <key> 0 -1 withscor...
Redis
8,078,018
153
My redis instance seems to being growing very large and I'd like to find out which of the multiple databases I have in there consumes how much memory. Redis' INFO command just shows me the total size and the number of keys per database which doesn't give me much insight... So any tools/ideas that give me more informati...
So my solution to my own problem: After playing around with redis-cli a bit longer I found out that DEBUG OBJECT <key> reveals something like the serializedlength of key, which was in fact something I was looking for... For a whole database you need to aggregate all values for KEYS * which shouldn't be too difficult wi...
Redis
7,638,542
146
This might be easy question but I am having a hard time finding the answer. How does Redis 2.0 handle running out of maximum allocated memory? How does it decide which data to remove or which data to keep in memory?
If you have virtual memory functionality turned on (EDIT: now deprecated), then Redis starts to store the "not-so-frequently-used" data to disk when memory runs out. If virtual memory in Redis is disabled (the default) and the maxmemory parameter is set (the default), Redis will not use any more memory than maxmemory a...
Redis
5,068,518
146
As you can see from the attached image, I've got a couple of workers that seem to be stuck. Those processes shouldn't take longer than a couple of seconds. I'm not sure why they won't clear or how to manually remove them. I'm on Heroku using Resque with Redis-to-Go and HireFire to automatically scale workers.
None of these solutions worked for me, I would still see this in redis-web: 0 out of 10 Workers Working Finally, this worked for me to clear all the workers: Resque.workers.each {|w| w.unregister_worker}
Redis
7,416,318
143
I was wondering how to disable presistence in redis. There is mention of the possibility of doing this here: http://redis.io/topics/persistence. I mean it in the exact same sense as described there. Any help would be very much appreciated!
To disable all data persistence in Redis do the following in the redis.conf file: Disable AOF by setting the appendonly configuration directive to no (it is the default value). like this: appendonly no Disable RDB snapshotting by commenting all of the save configuration directives (there are 3 that are defined by de...
Redis
28,785,383
137
Currently I'm working on python project that requires implement some background jobs (mostly for email sending and heavily database updates). I use Redis for task broker. So in this point I have two candidates: Celery and RQ. I had some experience with these job queues, but I want to ask you guys to share you experienc...
Here is what I have found while trying to answer this exact same question. It's probably not comprehensive, and may even be inaccurate on some points. In short, RQ is designed to be simpler all around. Celery is designed to be more robust. They are both excellent. Documentation. RQ's documentation is comprehensive w...
Redis
13,440,875
134
# I have the dictionary my_dict my_dict = { 'var1' : 5 'var2' : 9 } r = redis.StrictRedis() How would I store my_dict and retrieve it with redis. For example, the following code does not work. #Code that doesn't work r.set('this_dict', my_dict) # to store my_dict in this_dict r.get('this_dict') # to retriev...
You can do it by hmset (multiple keys can be set using hmset). hmset("RedisKey", dictionaryToSet) import redis conn = redis.Redis('localhost') user = {"Name":"Pradeep", "Company":"SCTL", "Address":"Mumbai", "Location":"RCP"} conn.hmset("pythonDict", user) conn.hgetall("pythonDict") {'Company': 'SCTL', 'Address': 'M...
Redis
32,276,493
133
There is a post about a Redis command to get all available keys, but I would like to do it with Python. Any way to do this?
Use scan_iter() scan_iter() is superior to keys() for large numbers of keys because it gives you an iterator you can use rather than trying to load all the keys into memory. I had a 1B records in my redis and I could never get enough memory to return all the keys at once. SCANNING KEYS ONE-BY-ONE Here is a python snipp...
Redis
22,255,589
133
Are there any good browsers/explorer for viewing Redis out there ? Am new to Redis so my expectation is if there is something similar to MongoVUE,Toad or SQLExplorer. I tried Redis Admin UI from service stack but ran into 500 error when trying on IIS
Redis Commander is great if you're using node.js already. Super simple to get going with NPM: npm install -g redis-commander redis-commander Then point your browser at the address in the console
Redis
12,292,351
131
I've just install Redis succesfully using the instructions on the Quick Start guide on http://redis.io/topics/quickstart on my Ubuntu 10.10 server. I'm running the service as dameon (so it can be run by init.d) The server is part of Rackspace Cluster with Internal and External IPs. The host is running on port 6379 (st...
I've been stuck with the same issue, and the preceding answer did not help me (albeit well written). The solution is here : check your /etc/redis/redis.conf, and make sure to change the default bind 127.0.0.1 to bind 0.0.0.0 Then restart your service (service redis-server restart) You can then now check that redis is...
Redis
8,537,254
130
We are defining an architecture to collect log information by Logstash shippers which are installed in various machines and index the data in one elasticsearch server centrally and use Kibana as the graphical layer. We need a reliable messaging system in between Logstash shippers and elasticsearch to grantee the delive...
After evaluating both Redis and RabbitMQ I chose RabbitMQ as our broker for the following reasons: RabbitMQ allows you to use a built in layer of security by using SSL certificates to encrypt the data that you are sending to the broker and it means that no one will sniff your data and have access to your vital organiz...
Redis
29,539,443
124
I'm able to connect to an ElastiCache Redis instance in a VPC from EC2 instances. But I would like to know if there is a way to connect to an ElastiCache Redis node outside of Amazon EC2 instances, such as from my local dev setup or VPS instances provided by other vendors. Currently when trying from my local set up: re...
SSH port forwarding should do the trick. Try running this from you client. ssh -f -N -L 6379:<your redis node endpoint>:6379 <your EC2 node that you use to connect to redis> Then from your client redis-cli -h 127.0.0.1 -p 6379 Please note that default port for redis is 6379 not 6739. And also make sure you allow the ...
Redis
21,917,661
121
I know there are three different, popular types of non-sql databases. Key/Value: Redis, Tokyo Cabinet, Memcached ColumnFamily: Cassandra, HBase Document: MongoDB, CouchDB I have read long blogs about it without understanding so much. I know relational databases and get the hang around document-based databases like Mo...
The main differences are the data model and the querying capabilities. Key-value stores The first type is very simple and probably doesn't need any further explanation. Data model: more than key-value stores Although there is some debate on the correct name for databases such as Cassandra, I'd like to call them column-...
Redis
3,554,169
121
I'm currently using MySql to store my sessions. It works great, but it is a bit slow. I've been asked to use Redis, but I'm wondering if it is a good idea because I've heard that Redis delays write operations. I'm a bit afraid because sessions need to be real-time. Has anyone experienced such problems?
Redis is perfect for storing sessions. All operations are performed in memory, and so reads and writes will be fast. The second aspect is persistence of session state. Redis gives you a lot of flexibility in how you want to persist session state to your hard-disk. You can go through http://redis.io/topics/persistence ...
Redis
10,278,683
117
I've heard of redis-cache but how exactly does it work? Is it used as a layer between django and my rdbms, by caching the rdbms queries somehow? Or is it supposed to be used directly as the database? Which I doubt, since that github page doesn't cover any login details, no setup.. just tells you to set some config pro...
This Python module for Redis has a clear usage example in the readme: http://github.com/andymccurdy/redis-py Redis is designed to be a RAM cache. It supports basic GET and SET of keys plus the storing of collections such as dictionaries. You can cache RDBMS queries by storing their output in Redis. The goal would be t...
Redis
3,801,379
112
I want to build my PHP-FPM image with php-redis extension based on the official PHP Docker image, for example, using this Dockerfile: php:5.6-fpm. The docs say that I can install extensions this way, installing dependencies for extensions manually: FROM php:5.6-fpm # Install modules (iconv, mcrypt and gd extensions) RU...
Redis is not an extension that is included in “php-src”, therefore you cannot use docker-php-ext-install. Use PECL: RUN pecl install --onlyreqdep --force redis \ && rm -rf /tmp/pear \ && docker-php-ext-enable redis On alpine php 7.3.5 we can use: RUN apk add --no-cache pcre-dev $PHPIZE_DEPS \ && pecl install redis \ &...
Redis
31,369,867
111
I want to remove keys that match "user*". How do I do that in redis command line?
Another compact one-liner I use to do what you want is: redis-cli KEYS "user*" | xargs redis-cli DEL
Redis
8,799,063
111
I was wondering what characters are considered valid in a Redis key. I have googled for some time and can not find any useful info. Like in Python, valid variable name should belong to the class [a-zA-Z0-9_]. What are the requirements and conventions for Redis keys?
Part of this is answered here, but this isn't completely a duplicate, as you're asking about allowed characters as well as conventions. As for valid characters in Redis keys, the manual explains this completely: Redis keys are binary safe, this means that you can use any binary sequence as a key, from a string like "f...
Redis
30,271,808
110
I would like to remove the debugging mode. I am using express, redis, socket.io and connect-redis, but I do not know where the debugging mode comes from. Someone has an idea?
Update To completely remove debugging use: var io = require('socket.io').listen(app, { log: false }); Where app is node.js http server / express etc. You forgot to mention you are also using socket.io. This is coming from socket.io. You can disable this by configuration: io.set('log level', 1); // reduce logging
Redis
6,807,775
110
How does Redis implement the expiration of keys? From here I learnt that Redis stores the time at which the key will expire, but how exactly is this implemented?
In short - for each redis object, there is an expiration time. Unless you set the object to expire, that time is "never". Now, the expiration mechanism itself is semi-lazy. Lazy expiration means that you don't actually expire the objects until they are read. When reading an object, we check its expiration timestamp, a...
Redis
36,172,745
107