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'm looking for an elegant way to define an api that can consume JSON data as well as form data. The following snippet works, but it's not elegant and requires all kind of ugly code in the backend. Is there a better way to define this?
What works right now:
paths:
/pets:
post:
consumes:
- application/... | OpenAPI 2.0
In OpenAPI 2.0, there's no way to describe that. Form and body parameters are mutually exclusive, so an operation can have either form data OR JSON body but not both. A possible workaround is to have two separate endpoints - one for form data and another one for JSON - if that is acceptable in your scenario... | OpenAPI | 42,287,298 | 10 |
I would like to describe the XML response payload of a RESTful interface with OpenAPI 2.0 (Swagger 2.0). However, I struggle describing a particular XML tag in the OpenAPI data model.
I can't get Swagger UI to create an appropriate example XML tag in this form, with an attribute and content between the opening and clos... | Unfortunately there's no way to represent that using the OpenAPI Specification 2.0, 3.0, or 3.1
This issue is being tracked here and could be addressed in future versions of the specification.
| OpenAPI | 42,023,864 | 10 |
Learning about REST APIs and am following https://apihandyman.io/writing-openapi-swagger-specification-tutorial-part-2-the-basics/.
The API can receive two parameters: username and bla, but only username is required by using the required keyword. This makes sense to me.
The API will return firstname, lastname, and use... | Your interpretation is correct. If a property of a response object is listed in the required property list, is must be present in the response object for it to be valid, quite similar to the required field in a parameter object. Whether a non-required property is included in the response or not is up to the business lo... | OpenAPI | 39,581,039 | 10 |
How are Packer and Docker different? Which one is easier/quickest to provision/maintain and why? What is the pros and cons of having a dockerfile?
| Docker is a system for building, distributing and running OCI images as containers. Containers can be run on Linux and Windows.
Packer is an automated build system to manage the creation of images for containers and virtual machines. It outputs an image that you can then take and run on the platform you require.
For v... | Packer | 47,169,353 | 76 |
I am sitting with a situation where I need to provision EC2 instances with some packages on startup. There are a couple of (enterprise/corporate) constraints that exist:
I need to provision on top of a specific AMI, which adds enterprisey stuff such as LDAP/AD access and so on
These changes are intended to be used for... | Using Packer to create finished (or very nearly finished) images drastically shortens the time it takes to deploy new instances and also allows you to use autoscaling groups.
If you have Terraform run a provisioner such as Chef or Ansible on every EC2 instance creation you add a chunk of time for the provisioner to run... | Packer | 49,314,752 | 28 |
I'm using packer with ansible provisioner to build an ami, and terraform to setup the infrastructure with that ami as a source - somewhat similar to this article: http://www.paulstack.co.uk/blog/2016/01/02/building-an-elasticsearch-cluster-in-aws-with-packer-and-terraform
When command packer build pack.json completes s... | You should consider using Terraform's Data Source for aws_ami. With this, you can rely on custom tags that you set on the AMI when it is created (for example a version number or timestamp). Then, in the Terraform configuration, you can simply filter the available AMIs for this account and region to get the AMI ID tha... | Packer | 37,357,618 | 23 |
I am struggling to pass input parameter to packer provisioning script. I have tried various options but no joy.
Objective is my provision.sh should accept input parameter which I send during packer build.
packer build -var role=abc test.json
I am able to get the user variable in json file however I am unable to pass i... | You should use the environment_vars option, see the docs Shell Provisioner - environment_vars.
Example:
"provisioners": [
{
"type": "shell"
"environment_vars": [
"HOSTNAME={{user `vm_name`}}",
"FOO=bar"
],
"scripts": [
"provision.sh"
],
}
]
| Packer | 47,596,369 | 22 |
I would like to build a Docker image without docker itself. I have looked at [Packer](http://www.packer.io/docs/builders/docker.html, but it requires that Docker be installed on the builder host.
I have looked at the Docker Registry API documentation but this information doesn't appear to be there.
I guess that the ima... | The Docker image format is specified here: https://github.com/docker/docker/blob/master/image/spec/v1.md
The simplest possible image is a tar file containing the following:
repositories
uniqid/VERSION
uniqid/json
uniqid/layer.tar
Where VERSION contains 1.0, layer.tar contains the chroot contents and json/repositories ... | Packer | 25,583,038 | 21 |
I've been looking at Packer.io, and would love to use it to provision/prepare the vagrant (VirtualBox) boxes used by our developers.
I know I could build the boxes with VirtualBox using the VirtualBox Packer builder, but find the layer stacking of Docker to provide a much faster development process of the boxes.
How do... | Find the size of the docker image from docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mybuntu 1.01 7c142857o35 2 weeks ago 1.94 GB
Run a container based on the image docker run mybuntu:1.01
Create a QEMU image from the container,
Also, use the size of the image in the first c... | Packer | 23,436,613 | 20 |
I'm using AWS Cloudformation to setup numerous elements of network infrastructure (VPCs, SecurityGroups, Subnets, Autoscaling groups, etc) for my web application. I want the whole process to be automated. I want click a button and be able to fire up the whole thing.
I have successfully created a Cloudformation template... | I like to separate out machine provisioning from environment provisioning.
In general, I use the following as a guide:
Build Phase
Build a Base Machine Image with something like Packer, including all software required to run your application. Create an AMI out of this.
Install the application(s) onto the Base Machine... | Packer | 28,824,594 | 17 |
So I'm trying to use Packer to create an AWS image and specify some user data via user_data_file. The contents of this file needs to be run when the instance boots as it will be unique each time. I can't bake this into the AMI.
Using packer I have the following:
{
"variables": {
"ami_name": ""
},
"builders": [... | Rereading this I think maybe you misunderstood how user-data scripts work with Packer.
user_data is provided when the EC2 instance is launched by Packer. This instance is in the end, after provisioning snapshoted and saved as an AMI.
When you launch new instances from the created AMI it doesn't have the same user-dat... | Packer | 45,110,795 | 14 |
I have a shell provisioner in packer connected to a box with user vagrant
{
"environment_vars": [
"HOME_DIR=/home/vagrant"
],
"expect_disconnect": true,
"scripts": [
"scripts/foo.sh"
],
"type": "shell"
}
where the content of the script is:
whoami
sudo su
whoami
and the output strangely remains:
==... | You should override the execute_command. Example:
"provisioners": [
{
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'",
"scripts": [
"scripts/foo.sh"
],
"type": "shell"
}
],
| Packer | 48,537,171 | 14 |
If I want to create a virtual machine image using Packer, one option is to download an operating system's ISO image and use that as the base for a custom setup. When doing this, one needs to provide the boot_command, which is an array of strings that tell Packer how to setup the operating system.
Now my question is: Ho... | The boot_command depends on OS you want to install and are just the keystrokes that are needed to start an automatted installation.
For Ubuntu/Debian it is called preseeding, for Red Hat/CentOS/SLES there are kickstart files, and other Linux distributions probably have similar features.
For Ubuntu a starting point is t... | Packer | 31,370,750 | 12 |
From ubuntu shell I ran below command, to talk to aws platform, to customise amazon ami(ami-9abea4fb):
$ packer build -debug template.packer
Debug mode enabled. Builds will not be parallelized.
amazon-ebs output will be in this color.
==> amazon-ebs: Prevalidating AMI Name...
==> amazon-ebs: Pausing after run of step... | Unless Packer is given a private SSH with the ssh_private_key_file Packer creates an ephemeral that is only kept in memory while Packer is running.
When you run with the -debug flag this ephemeral key is saved into the current working directory. This is to enable you to troubleshoot the build by manually SSH'ing into t... | Packer | 59,440,394 | 11 |
I am extremely confused on why this occurs when using Packer. What I want to do is move a local redis.conf file over to my AMI; however, it gives me an error as I do this. My Packer provisioner is like so:
{
"type": "file",
"source": "../../path/to/file/redis.conf",
"destination": "/etc/redis/redis.conf"
... | What you need to do is copy the file to a location where you have write access (/tmp for example) and then use an inline provisioner to move it somewhere else.
I have something like:
provisioner "file" {
source = "some/path/to/file.conf"
destination = "/tmp/file.conf
}
And then:
provisioner "shell" {
inline... | Packer | 67,095,815 | 11 |
I would like to generate a public/private ssh key pair during packer provisioning and copy the files to the host machine. Is there a way to copy files out from the VM to the host using packer?
| I figured it out. The file provisioner has a "direction" option that allows download instead of upload
{
"type": "file",
"source": "app.tar.gz",
"destination": "/tmp/app.tar.gz",
"direction" : "download"
}
| Packer | 36,511,571 | 10 |
I have used hashicorp packer for building baked VM images.
But was wondering linuxkit too do the same stuff I mean building the baked VM images with the only difference of being more container and kernel centeric.
Want to know the exact difference between the working of these two and there use cases.
Also can there b... | I have used both fairly extensively (disclosure: I am a volunteer maintainer for LinuxKit). I used packer for quite some time, and switched almost all of the work I did in packer over to LinuxKit (lkt).
In principle both are open-source tools that serve the same purpose: generate an OS image that can be run. Practical... | Packer | 47,812,633 | 10 |
No matter what I do, I only ever get a 404 or Error: invalid reference format
I think it should be podman pull hub.docker.com/_/postgres
but this doesn't work. I've also tried
podman pull hub.docker.com/postgres
podman pull hub.docker.com/__/postgres
podman pull hub.docker.com/library/postgres
Any ideas what's neede... | In order to pull images from Docker Hub using podman, the image name needs to be prefixed by the docker.io/ registry name.
To get the 'official images' they are part of the 'library' collection.
So to pull Postgres from Docker Hub using Podman, the command is
podman pull docker.io/library/postgres
| Podman | 69,162,077 | 31 |
I want to run podman as a container to run CI/CD pipelines. However, I keep getting this error from the podman container:
$ podman info
ERRO[0000] 'overlay' is not supported over overlayfs
Error: could not get runtime: 'overlay' is not supported over overlayfs: backing file system is unsupported for this graph driver
... | Your Dockerfile should install iptables as well:
FROM ubuntu:16.04
RUN apt-get update -qq \
&& apt-get install -qq -y software-properties-common uidmap \
&& add-apt-repository -y ppa:projectatomic/ppa \
&& apt-get update -qq \
&& apt-get -qq -y install podman \
&& apt-get install -y iptables
# To ... | Podman | 56,032,747 | 30 |
I recently found out about Podman (https://podman.io). Having a way to use Linux fork processes instead of a Daemon and not having to run using root just got my attention.
But I'm very used to orchestrate the containers running on my machine (in production we use kubernetes) using docker-compose. And I truly like it.
S... | Yes, that is doable now, check podman-compose, this is one way of doing it, another way is to convert the docker-compose yaml file to a kubernetes deployment using Kompose. there is a blog post from Jérôme Petazzoni @jpetazzo: from docker-compose to kubernetes deployment
| Podman | 55,154,393 | 27 |
What I am trying to accomplish is to connect to a database installed on the host system. Now there is a similar question already for docker, but I could not get that to work with Podman, I imagine because networking works a bit differently here.
My solution so far has been to use --add-host=dbhost:$(ip route show dev c... | You can also use host.containers.internal in podman. It's basically Podman's equivalent to host.docker.internal, but works out of the box.
| Podman | 58,678,983 | 24 |
When I do something like podman rmi d61259d8f7a7 -f it fails with a message: Error: unable to delete "vvvvvvvvvvvv" (cannot be forced) - image has dependent child images.
I already tried the all switch podman rmi --all which does delete some images but many are still left behind. How do I force remove all images and de... | Inspired by a similar docker answer with a slight modification, adding the a was the missing magic in my case:
WARNING: This will delete every image! Please, check and double check that it is indeed what you need.
$ podman rmi $(podman images -qa) -f
Again, please use with caution and make sure you know what you're do... | Podman | 63,287,522 | 24 |
I'm trying to use Podman for local development. My idea is to use a local folder and sync it with the container where I'll be running my application.
I found that the -v option that I would use if I was working with Docker works with the server machine, as it says in the documentation -v Bind mount a volume into the co... | podman machine stop podman-machine-default
podman machine rm podman-machine-default
podman machine init -v $HOME:$HOME
podman machine start
podman run -ti --rm -v $HOME:$HOME busybox
| Podman | 69,298,356 | 24 |
The Google Container Registry documentation provides very good help on authenticating to it with Docker. Is there a way to do the same with Podman? The Google doc mentions Access Token as a method. Maybe that could work. If anybody has any advice or experience of this, I'd really appreciate your help
| gcloud auth print-access-token | podman login -u oauth2accesstoken --password-stdin XX.gcr.io
xx.gcr.io is the host name. For example https://us.gcr.io, etc.
oauth2accesstoken is a special username that tells it to get all identity information from the token passed as a password.
See this doc.
| Podman | 63,790,529 | 16 |
I am trying to build a large image with Podman. The build fails with
Reached heap limit Allocation failed
error.
In docker I can avoid this by allocating more memory for docker engine in docker settings.
However, for Podman it doesn't seem to be so easy.
I tried to modify ~/.config/containers/podman/machine/qemu/podm... | The following commands are also very handy for quick resolution.
podman machine stop
podman machine set --cpus 2 --memory 2048
podman machine start
Source: https://github.com/containers/podman/issues/12713#issuecomment-1002567777
| Podman | 70,114,200 | 16 |
Is it possible to use Testcontainers with Podman in Java tests?
As of March 2022, the Testcontainers library doesn't detect an installed Podman as a valid Docker environment.
Can Podman be a Docker replacement on both MacOS with Apple silicon (local development environment) and Linux x86_64 (CI/CD environment)?
| It is possible to use Podman with Testcontainers in Java projects, that use Gradle on Linux and MacOS (both x86_64 and Apple silicon).
Prerequisites
Podman Machine and Remote Client are installed on MacOS - https://podman.io/getting-started/installation#macos
Podman is installed on Linux - https://podman.io/getting-st... | Podman | 71,549,856 | 15 |
Is there a way to run Podman inside Podman, similar to the way you can run Docker inside Docker?
Here is a snippet of my Dockerfile which is strongly based on another question:
FROM debian:10.6
RUN apt update && apt upgrade -qqy && \
apt install -qqy iptables bridge-utils \
qemu-kvm libvirt-da... | Assume we would like to run ls / in a docker.io/library/alpine container.
Standard Podman
podman run --rm docker.io/library/alpine ls /
Podman in Podman
Let's run ls / in a docker.io/library/alpine container, but this time we run podman in a quay.io/podman/stable container.
Update June 2021
A GitHub issue comment sh... | Podman | 64,509,618 | 14 |
I'm asking this question despite having read similar but not exactly what I want at C# naming convention for enum and matching property
I found I have a tendency to name enums in plural and then 'use' them as singular, example:
public enum EntityTypes {
Type1, Type2
}
public class SomeClass {
/*
some codes
*... | Microsoft recommends using singular for Enums unless the Enum represents bit fields (use the FlagsAttribute as well). See Enumeration Type Naming Conventions (a subset of Microsoft's Naming Guidelines).
To respond to your clarification, I see nothing wrong with either of the following:
public enum OrderStatus { Pending... | Plural | 1,405,851 | 361 |
I want to be able to translate pluralized strings in i18n in rails. A string can be :
You have 2 kids
or
You have 1 kid
I know that I can use pluralize helper method, but I want to embed this in i18n translations so that I don't have to mess up with my views at any point in the future. I read that :count is somehow u... | Try this:
en.yml :
en:
misc:
kids:
zero: no kids
one: 1 kid
other: %{count} kids
In a view:
You have <%= t('misc.kids', :count => 4) %>
Updated answer for languages with multiple pluralization (tested with Rails 3.0.7):
File config/initializers/pluralization.rb:
require "i18n/backend/pluraliz... | Plural | 6,166,064 | 96 |
I am trying to use the getQuantityString method in Resources to retrieve quantity strings (plurals) based on Android Developer guidelines Quantity string (plurals)
The error I am getting is
Error:(604) Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?
Erro... | You don't need to set the "formatted" attribute for any of those items. When using quantity strings, there are only three possibilities:
the resource string is plain text and does not contain any parameters
the resource string contains only one parameter (most likely the quantity); use %d or whatever format you need
t... | Plural | 41,950,952 | 84 |
I use plurals to compile a quantity string for an Android application. I follow exactly what one can find in the tutorials:
res.getQuantityString(
R.plurals.number_of_comments, commentsCount, commentsCount);
Here is the definition of the plurals:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<plurals name... | According to the documentation :
The selection of which string to use is made solely based on
grammatical necessity. In English, a string for zero will be ignored
even if the quantity is 0, because 0 isn't grammatically different
from 2, or any other number except 1 ("zero books", "one book", "two
books", and ... | Plural | 17,261,290 | 39 |
I was going to use Java's standard i18n system with the ChoiceFormat class for plurals, but then realized that it doesn't handle the complex plural rules of some languages (e.g. Polish). If it only handles languages that resemble English, then it seems a little pointless.
What options are there to achieve correct plura... | Well, you already tagged the question correctly, so I assume you know thing or two about ICU.
With ICU you have two choices for proper handling of plural forms:
PluralRules, which gives you the rules for given Locale
PluralFormat, which uses aforementioned rules to allow formatting
Which one to use? Personally, I pre... | Plural | 14,326,653 | 38 |
I'm looking for a function that given a string it switches the string to singular/plural. I need it to work for european languages other than English.
Are there any functions that can do the trick? (Given a string to convert and the language?)
Thanks
| Here is my handy function:
function plural( $amount, $singular = '', $plural = 's' ) {
if ( $amount === 1 ) {
return $singular;
}
return $plural;
}
By default, it just adds the 's' after the string. For example:
echo $posts . ' post' . plural( $posts );
This will echo '0 posts', '1 post', '2 posts... | Plural | 4,728,933 | 27 |
In Android strings, you can define plurals to handle translations depending on the actual number supplied to the string as described here.
Strings also allow for specifying multiple positional parameters similar to what sprintf does in many languages.
However, consider the following string:
<resources>
<string name... | Previous answer uses string concatenation which is incorrect from an i18n point of view. For the original string "%1$d hours and %2$d minutes remaining." using string concatenation would force the translation of "remaining" to the end which mightn't be appropriate for some languages.
My solution would be:
<resources>
... | Plural | 34,393,271 | 19 |
I have txt files that look like this:
word, 23
Words, 2
test, 1
tests, 4
And I want them to look like this:
word, 23
word, 2
test, 1
test, 4
I want to be able to take a txt file in Python and convert plural words to singular. Here's my code:
import nltk
f = raw_input("Please enter a filename: ")
def openfile(f):
... | If you have complex words to singularize, I don't advise you to use stemming but a proper python package link pattern :
from pattern.text.en import singularize
plurals = ['caresses', 'flies', 'dies', 'mules', 'geese', 'mice', 'bars', 'foos',
'families', 'dogs', 'child', 'wolves']
singles = [singularize(plu... | Plural | 31,387,905 | 14 |
Background
I work on an app that has many translations inside it.
I have the next English plural strings:
<plurals name="something">
<item quantity="one">added photo</item>
<item quantity="other">added %d photos</item>
</plurals>
and the French translation:
<plurals name="something">
<item quantity="one">a... | I'm going to write an answer since this is quite an difficult explanation.
In various languages, nouns use the singular form if they end with 1. Refer to: http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html
Explaining in English there are languages where it's correct to say "added 1 photo"... | Plural | 26,159,556 | 13 |
This is about best practices in general, not specific for a single language, database or whatever
We all have to deal with generated output where you can be reporting "one products" or "two product". Doesn't read very well... Some just solve this by using "one product(s)" or "number of products: (1)" and others might h... | I'd recommend taking a look at gettext in general and ngettext in particular. Maybe even if you're not going to translate your application. Just head to this part of the documentation. It has implementation for more or less all languages and even if your language of choice lacks this support, nothing stops you from bor... | Plural | 1,438,093 | 12 |
Android allows translators to define Plurals. The following example works for me with locale 'en':
<plurals name="numberOfSongsAvailable">
<item quantity="one">One song found.</item>
<item quantity="other">%d songs found.</item>
</plurals>
But adding a special value for two does not work, still the other versi... | Android is using the CLDR plurals system, and this is just not how it works (so don't expect this to change).
The system is described here:
http://cldr.unicode.org/index/cldr-spec/plural-rules
In short, it's important to understand that "one" does not mean the number 1. Instead these keywords are categories, and the sp... | Plural | 8,473,816 | 12 |
My question is similar to How to add regular string placeholders to a translated plurals .stringdict in swift ios but I am trying to understand if it is possible to pass 2 int parameters to strings dict.
Say if I want to translate something like:
1 apple : 3 pears
2 apples : 1 pear
Is it possible to do it in one local... | One format is sufficient. You can use multiple placeholders in the NSStringLocalizedFormatKey entry, and for each placeholder a separate dictionary with the plural rule. Example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">... | Plural | 55,752,969 | 12 |
I am trying to build and deploy microservices images to a single-node Kubernetes cluster running on my development machine using minikube. I am using the cloud-native microservices demo application Online Boutique by Google to understand the use of technologies like Kubernetes, Istio etc.
Link to github repo: microser... | There are a few reasons why you encounter these errors:
There might be an issue with the existing cache and/or disc space. In order to fix it you need to clear the APT cache by executing: sudo apt-get clean and sudo apt-get update.
The same goes with existing docker images. Execute: docker image prune -f and docker c... | Skaffold | 62,473,932 | 221 |
I work with teams members to develop a microservices architecture but I have a problem with the way to work. Indeed, I have too many microservices and when I run them during my development, it consumes too memory even with a good workstation. So I use docker compose to build and execute my MSA but it takes a long time.... | I've had a fair amount of experience with microservices and local development and here's been some approaches I've seen:
Run all the things locally on docker or k8. If using k8, then a tool like skaffolding can make it easier to run and debug a service locally in the IDE but put it into your local k8 so that it can co... | Skaffold | 64,251,489 | 43 |
I'm using Redis-server for windows ( 2.8.4 - MSOpenTech) / windows 8 64bit.
It is working great , but even after I run :
I see this : (and here are my questions)
When Redis-server.exe is up , I see 3 large files :
When Redis-server.exe is down , I see 2 large files :
Question :
— Didn't I just tell it to erase ... | From https://github.com/MSOpenTech/redis/issues/83
"Redis uses the fork() UNIX system API to create a point-in-time snapshot of the data store for storage to disk. This impacts several features on Redis: AOF/RDB backup, master-slave synchronization, and clustering. Windows does not have a fork-like API available, so we... | Redis | 23,662,131 | 27 |
I am unable to run the resque-web on my server due to some issues I still have to work on but I still have to check and retry failed jobs in my resque queues.
Has anyone any experience on how to peek the failed jobs queue to see what the error was and then how to retry it using the redis-cli command line?
thanks,
| Found a solution on the following link:
http://ariejan.net/2010/08/23/resque-how-to-requeue-failed-jobs
In the rails console we can use these commands to check and retry failed jobs:
1 - Get the number of failed jobs:
Resque::Failure.count
2 - Check the errors exception class and backtrace
Resque::Failure.all(0,20).e... | Redis | 8,798,357 | 27 |
I'd like to use Redis features such as bitfields and hashfields from an MVC controller. I understand there's built in caching support in ASP.NET core but this only supports basic GET and SET commands, not the commands that I need in my application. I know how to use StackExchange.Redis from a normal (eg. console) appli... | In your Startup class's ConfigureServices method, you'll want to add:
services.AddSingleton<IConnectionMultiplexer>(ConnectionMultiplexer.Connect("yourConnectionString"));
You can then use the dependency injection by changing your constructor signature to something like this:
public YourController : Controller
{
p... | Redis | 46,368,234 | 26 |
There is a very good SQL client solution for Linux users DBeaver. In spec, it is said that it supports MongoDB and Redis databases.However, there are no such drivers in "New connection" window. Does anyone know how to connect to Mongo or Redis?
| The Enterprise edition has MongoDB and Redis support.
EE download
We have split standalone version on Community and Enterprise editions.
Community edition includes the same extensions as DBeaver 2.x.
Enterprise edition = Community edition + NoSQL support (Cassandra and
MongoDB in 3.0). Both Community and Enterpr... | Redis | 40,256,591 | 26 |
I have installed redis with laravel by adding "predis/predis":"~1.0",
Then for testing i added the following code :
public function showRedis($id = 1)
{
$user = Redis::get('user:profile:'.$id);
Xdd($user);
}
In app/config/database.php i have :
'redis' => [
'cluster' => false,
'defaul... | I had this issue in Ubuntu 18.04
I installed redis in my local system, got solved.
sudo apt-get install redis-server
| Redis | 38,604,524 | 26 |
The Basic Usage documentation for StackExchange.Redis explains that the ConnectionMultiplexer is long-lived and is expected to be reused.
But what about when the connection to the server is broken? Does ConnectionMultiplexer automatically reconnect, or is it necessary to write code as in this answer (quoting that answe... | Here is the pattern recommended by the Azure Redis Cache team:
private static Lazy<ConnectionMultiplexer> lazyConnection = new Lazy<ConnectionMultiplexer>(() => {
return ConnectionMultiplexer.Connect("mycache.redis.cache.windows.net,abortConnect=false,ssl=true,password=...");
});
public static ConnectionMultiplexe... | Redis | 28,792,196 | 26 |
I would like to be notified when a volatile key expires in my redis store. The redis website provides some description of how this might be achieved in http://redis.io/topics/notifications, but I am wondering if it can be done using the python redis api.
After setting:notify-keyspace-events Ex in my redis.conf file
an... | The surprise (no expiration events seen when time to live for a key reaches zero) is not bound to Python, but rather to the way, Redis is expiring keys.
Redis doc on Timing of expired events
Timing of expired events
Keys with a time to live associated are expired by Redis in two ways:
When the key is accessed by a com... | Redis | 23,964,548 | 26 |
I have my config file at:
root/config/redis.rb
I start redis like this: redis-server
How do I start redis so that it uses my config file?
Also, I hate mucking about with ps -grep to try and find a pid to shut it down. How can I shut down the server by cd'ing into the root and running just one command?
With the puma app... | Okay, redis is pretty user friendly but there are some gotchas.
Here are just some easy commands for working with redis on Ubuntu:
install:
sudo apt-get install redis-server
start with conf:
sudo redis-server <path to conf>
sudo redis-server config/redis.conf
stop with conf:
redis-cli shutdown
(not sure how this shu... | Redis | 23,496,546 | 26 |
The use case is to use Redis to be local cache of MySQL
The data format in MySQL is: a single primary key and several other fields. There will not be queries cross table of db
Redis key is primary key in MySQL, and value is hash containing other fields in MySQL
When power off, less than one minute data lose is accepta... | You don't need to hack anything ;)
I am not entirely sure why you need the data on mysql. If I knew, maybe there would be a more suitable answer. In any case, as a generic answer you can use redis keyspace notifications
You could subscribe to the commands HSET, HMSET, HDEL and DEL on your keys, so you would get a notif... | Redis | 23,080,557 | 26 |
Requirement :
Python objects with 2-3 levels of nesting containing basic datypes like integers,strings, lists, and dicts.
( no dates etc), needs to be stored as json in redis against a key.
What are the best methods available for compressing json as a string for low memory footprint.
The target objects are not very lar... | We just use gzip as a compressor.
import gzip
import cStringIO
def decompressStringToFile(value, outputFile):
"""
decompress the given string value (which must be valid compressed gzip
data) and write the result in the given open file.
"""
stream = cStringIO.StringIO(value)
decompressor = gzip.GzipFile(fil... | Redis | 15,525,837 | 26 |
I need to see what redis gets/sets in the redis log.
I tried to set the redis log level to debug and verbose.
This does not show me anything when I set a value.
| Unless it's important that you get in the log, in which case I don't think I can help you, you should be able to use the MONITOR command:
MONITOR is a debugging command that streams back every command processed by the Redis server. It can help in understanding what is happening to the database. This command can both b... | Redis | 14,713,084 | 26 |
I use INCR and EXPIRE to implement rate limiting, e.g., 5 requests per minute:
if EXISTS counter
count = INCR counter
else
EXPIRE counter 60
count = INCR counter
if count > 5
print "Exceeded the limit"
However, 5 requests can be sent at the last second minute one and 5 more requests at the first s... | You could switch from "5 requests in the last minute" to "5 requests in minute x". By this it would be possible to do:
counter = current_time # for example 15:03
count = INCR counter
EXPIRE counter 60 # just to make sure redis doesn't store it forever
if count > 5
print "Exceeded the limit"
If you want to keep usin... | Redis | 13,175,050 | 26 |
I am trying to store a wordlist in redis. The performance is great.
My approach is of making a set called "words" and adding each new word via 'sadd'.
When adding a file thats 15.9 MB and contains about a million words, the redis-server process consumes 160 MB of ram. How come I am using 10x the memory, is there any be... | Well this is expected of any efficient data storage: the words have to be indexed in memory in a dynamic data structure of cells linked by pointers. Size of the structure metadata, pointers and memory allocator internal fragmentation is the reason why the data take much more memory than a corresponding flat file.
A Re... | Redis | 10,004,565 | 26 |
Does anyone have a solid pattern fetching Redis via BookSleeve library?
I mean:
BookSleeve's author @MarcGravell recommends not to open & close the connection every time, but rather maintain one connection throughout the app. But how can you handle network breaks? i.e. the connection might be opened successfully in the... | Since I haven't got any good answers, I came up with this solution (BTW thanks @Simon and @Alex for your answers!).
I want to share it with all of the community as a reference. Of course, any corrections will be highly appreciated.
using System;
using System.Net.Sockets;
using BookSleeve;
namespace Redis
{
public ... | Redis | 8,645,953 | 26 |
I need to save a User model, something like:
{ "nickname": "alan",
"email": ...,
"password":...,
...} // and a couple of other fields
Today, I use a Set: users
In this Set, I have a member like user:alan
In this member I have the hash above
This is working fine but I was just wondering if instead of the above ... | You can use Redis hashes data structure to store your JSON object fields and values. For example your "users" set can still be used as a list which stores all users and your individual JSON object can be stored into hash like this:
db.hmset("user:id", JSON.stringify(jsonObj));
Now you can get by key all users or only ... | Redis | 5,729,891 | 26 |
My team wants to move to microservices architecture. Currently we are using Redis Pub/Sub as message broker for some legacy parts of our system. My colleagues think that it is naturally to continue use redis as service bus as they don't want spend their time on studying new product. But in my opinion RabbitMQ (especial... | Redis is a fast in-memory key-value store with optional persistence. The pub/sub feature of Redis is a marginal case for Redis as a product.
RabbitMQ is the message broker that does nothing else. It is optimized for reliable delivery of messages, both in command style (send to an endpoint exchange/queue) and publish-su... | Redis | 52,592,796 | 25 |
Background
I am making a publish/subscribe typical application where a publisher sends messages to a consumer.
The publisher and the consumer are on different machines and the connection between them can break occasionally.
Objective
The goal here is to make sure that no matter what happens to the connection, or to t... | Background
I originally wanted publish and subscribe with message and queue persistence.
This in theory, does not exactly fit publish and subscribe:
this pattern doesn't care if the messages are received or not. The publisher simply fans out messages and if there are any subscribers listening, good, otherwise it doe... | Redis | 43,777,807 | 25 |
We know that ElastiCache is not recommended to be accessed outside Amazon instances, so we're trying below stuff inside Amazon EC2 instances only.
We've got a ElastiCache Redis Cluster with 9 nodes. When we try to connect to it using normal redis implementation, it throws some Moved errors
Have tried the retry strat... |
Sharing the code for future readers:
var RedisClustr = require('redis-clustr');
var RedisClient = require('redis');
var config = require("./config.json");
var redis = new RedisClustr({
servers: [
{
host: config.redisClusterHost,
port: config.redisClusterPort
}
],
c... | Redis | 43,872,852 | 25 |
If I run the redis:alpine Docker image using the commmand
docker run redis:alpine
I see several warnings:
1:C 08 May 08:29:32.308 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_._ ... | Bad way to handle things: /proc is read-only filesystem to modify it you can run Docker in privileged mode than you can modify it after the container was started.
If running the container in privileged mode, you can disable THP using these commands:
# echo never > /sys/kernel/mm/transparent_hugepage/enabled
# echo neve... | Redis | 43,843,197 | 25 |
Hello when trying to use spring-redis i am getting
java.lang.NoClassDefFoundError: Could not initialize class org.springframework.data.redis.connection.jedis.JedisConnection
exception when doing any connection operation using redis. My config method goes like this
@Bean
public RedisConnectionFactory jedisConnFactor... | After wasting almost one day and finding that the jar is already on my class path, i further debugged it and found that when java's reflection mechanism was trying to find a method which was already present in the "methods list" it was not able to find due to some version conflict between Jedis version (2.7.2) not comp... | Redis | 33,128,318 | 25 |
I wish to install redis on my red-hat environment. I do the following:
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
I got the next error:
make[3]: *** [net.o] Error 127
make[3]: Leaving directory `/tmp/redis-stable/deps/hiredis'
make[2]: *** [hiredis] Error 2
mak... | You are trying to install redis from source code. What this process do is to compile and create executable on your machine and then install it. For doing this you need various tools like gcc etc. Best way is to install all of them together by installing that group. Run this from terminal
yum grouplist
This will show ... | Redis | 30,692,708 | 25 |
I am looking around redis to provide me an intermediate cache storage with a lot of computation around set operations like intersection and union.
I have looked at the redis website, and found that the redis is not designed for a multi-core CPU. My question is, Why is it so ?
Also, if yes, how can we make 100% utilizat... |
I have looked at the redis website, and found that the redis is not designed for a multi-core CPU. My question is, Why is it so?
It is a design decision.
Redis is single-threaded with epoll/kqueue and scales indefinitely in terms of I/O concurrency. --@antirez (creator of Redis)
A reason for choosing an event-drive... | Redis | 21,304,947 | 25 |
I am currently using django with celery and everything works fine.
However I want to be able to give the users an opportunity to cancel a task if the server is overloaded by checking how many tasks are currently scheduled.
How can I achieve this ?
I am using redis as broker.
I just found this :
Retrieve list of tasks ... | Here is how you can get the number of messages in a queue using celery that is broker-agnostic.
By using connection_or_acquire, you can minimize the number of open connections to your broker by utilizing celery's internal connection pooling.
celery = Celery(app)
with celery.connection_or_acquire() as conn:
conn.de... | Redis | 18,631,669 | 25 |
I would like to export a subset of my Redis data on the slave to a csv file. I notice a new csv output option was added to redis-cli but I am unable to find documentation of how it works. Enabling the option prints the command outputs to screen in csv format. What is the best way to get this into a csv file?
| Cutting edge!
I've just looked at the source code & all it does is output the commands as comma separated values to stdout. Which is no big surprise.
So you could just redirect it to a file, in the standard way, as long as you're on Linux?
e.g./
redis-cli --csv your-command > stdout.csv 2> stderr.txt
| Redis | 11,368,615 | 25 |
I have been using heroku redis for a while now on one of my side projects. I currently use it for 3 things
It serves as a place for me to store firebase certificates
It is used for caching data on the site
It is used for rails sidekiq jobs
Recently, my heroku usage went up and I had to change it to use heroku redis p... | According to Heroku's docs
You need to
Create an initializer file named config/initializers/redis.rb
containing:
$redis = Redis.new(url: ENV["REDIS_URL"], ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE })
Also if you are having this issue while attempting to use sidekiq:
Create an initializer file named confi... | Redis | 66,246,528 | 24 |
How can I browse all the pending jobs within my Redis queue so that I could cancel the Mailable that has a certain emailAddress-sendTime pair?
I'm using Laravel 5.5 and have a Mailable that I'm using successfully as follows:
$sendTime = Carbon::now()->addHours(3);
Mail::to($emailAddress)
->bcc([config('mail.suppo... | Make it easier.
Don't send an email with the later option. You must dispatch a Job with the later option, and this job will be responsible to send the email.
Inside this job, before send the email, check the emailAddress-sendTime pair. If is correct, send the email, if not, return true and the email won't send and th... | Redis | 48,255,735 | 24 |
I am creating a node API using javascript. I have used redis as my key value store.
I created a redis-client in my app and am able to get values for perticular key.
I want to retrieve all keys along with their values.
So Far I have done this :
app.get('/jobs', function (req, res) {
var jobs = [];
client.keys('*... | First of all, the issue in your question is that, inside the for loop, client.get is invoked with an asynchronous callback where the synchronous for loop will not wait for the asynchronous callback and hence the next line res.json({data:jobs}); is getting called immediately after the for loop before the asynchronous ca... | Redis | 42,926,990 | 24 |
I'm trying to access Redis server through the code and it's not connecting. But if i bash to the redis container i can access the redis-cli.
docker-compose.yml looks like this
version: '2'
services:
web:
build:
context: .
dockerfile: Dockerfile_nginx
ports:
- "9000:80"
environment:
- NGINX_SE... | Your Problem
Docker Compose creates separated docker container for different services. Each container are, logically speaking, like different separated computer servers that only connected with each other through docker network.
Consider each boxes in this diagram as an individual computer, then this is practically wha... | Redis | 42,360,356 | 24 |
I am working on the project which need to broadcast latitude and longitude on realtime
I have something like below
namespace App\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Support\Facades\Redis;
class TrackersBroadcast ext... | Because Laravel Event Broadcasting queued by default if you extend ShouldBroadcast interface. If you don't want Event Broadcasting queued, you should extend ShouldBroadcastNow interface.
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
class TrackersBroadcast implements ShouldBroadcastNow
{
......
}
So It me... | Redis | 41,390,753 | 24 |
How can i change the name of databases in redis? Example:
Db01
key01
key02
Db02
key01
key02
Db03
key01
key02
i want to change db01 name or db02, db03 to other names
| Redis databases are identified by an integer index, there is no database name.
By default there are 16 databases, indexed from 0 to 15.
Check the following article: https://www.digitalocean.com/community/cheatsheets/how-to-manage-redis-databases-and-keys
| Redis | 35,931,043 | 24 |
I am looking for a very simple starter C# application for using StackExchange.Redis
I have search over the web and found StackExchange.Redis
But this doesn't seems like a quick startup example.
I have setup redis on windows using
StackExchange.Redis exe
Can anyone help me locate a simple C# application connecting with... | You can find C# examples in the readme file.
using StackExchange.Redis;
...
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
// ^^^ store and re-use this!!!
IDatabase db = redis.GetDatabase();
string value = "abcdefg";
db.StringSet("mykey", value);
...
string value = db.StringGet("mykey");
Co... | Redis | 32,888,513 | 24 |
Is there any way to Remove all Redis Client Connections with one command?
I know that it's possible to remove by IP:PORT
CLIENT KILL addr:port
Also I found that is possible to do this since Redis 2.8.12.
But
I couldn't find anything about.
| CLIENT KILL can receive TYPE argument that can be one of a three connection types; normal, slave and pubsub.
You can kill all open connections by sending the following three commands:
CLIENT KILL TYPE normal
CLIENT KILL TYPE slave
CLIENT KILL TYPE pubsub
Note that you can skip the later two if you do not use them (sla... | Redis | 30,790,748 | 24 |
I'd like to view the time of most recent access for a specific key on my redis server.
I know that this information is stored for each key because it is used in redis's LRU algorithm for eliminating old keys.
Is there an easy way to see this information for a given key?
| You can use the OBJECT IDLETIME command for this purpose. It returns the number of seconds since the key was accessed, but If you need the time just subtract the reply from now().
| Redis | 26,245,623 | 24 |
AWS has Redis support via the ElastiCache Service. My question is, can I connect to Redis on AWS Elasticache from node, using the following:
var client = require('redis').createClient(6379, 'elastichache endpoint string', {no_ready_check: true});
Or do I have to use the NodeJS AWS SDK?
I realize I could set up my own ... | Yes, this is a common use case. You can connect directly to redis without using the SDK. Just make sure you have configured the security group correctly to allow access from your app server.
| Redis | 22,432,818 | 24 |
Suppose my database table structure is like this
id name college address
1 xxx nnn xn
2 yyy nnm yn
3 zzz nnz zn
If i want to get the student details based on the name in sql like this
select * from student where name = 'xxx'
so how its is possible in redis database
| Redis, like other NoSQL datastores, has different requirements based on what you are going to be doing.
Redis has several data structures that could be useful depending on your need. For example, given your desire for a select * from student where name = 'xxx' you could use a Redis hash.
redis 127.0.0.1:6379> hmset st... | Redis | 21,347,437 | 24 |
An inspection of currently running Celery tasks reveals a weird time_start timestamp:
>> celery.app.control.inspect().active()
{u'celery@worker.hostname': [{u'acknowledged': True,
u'args': u'(...,)',
u'delivery_info': {u'exchange': u'celery',
u'priority': 0,
u'redelivered': None,
u'routing_key': u'cel... | I found the answer to my own question by digging in the Celery and Kombu code: the time_start attribute of a task is computed by the kombu.five.monotonic function. (Ironically, the kombu code also refers to another StackOverflow question for reference) The timestamp returned by that function refers to a "monotonic" tim... | Redis | 20,091,505 | 24 |
I wanted to make some changes in redis.conf, so that whenever i type redis-cli it connects me to redis installed on remote server.
I know that we can connect to redis installed on remote server by :
redis-cli -h 'IP-Address-Of-Server'.
But actually, I have some bash scripts and in those scripts i have used redis-cl... | there is no good reason to touch redis conf for this.
just make a script that wraps redis-cli with the desired parameters to connect to the remote host
eg. create a redis-cli-remotename.sh
#!/bin/sh
redis-cli -h remote.host_name
and give it +x permissions (eg. chmod +x redis-cli-remotename.sh)
| Redis | 16,817,996 | 24 |
I am using node.js to write a web service, it calls an API for some data but I am limited by the API to a number of calls per month, so I wish to cache the data I retrieve from the API so I can serve it up with the cached data, and re-fetch the data from the API at a timed interval.
Is this a good approach for this pr... | I would disagree with you regarding Redis. Redis is a very powerful key-value store that can easily be used for what you want. It is designed to have stuff dumped in it and taken out again. In your situation, you can easy cache the API response by saving it into Redis with the query as the key (if this is a REST API yo... | Redis | 15,607,180 | 24 |
I've been considering using Redis in a project that uses a lot of writes.
So, after setting it up on my server, I created a simple PHP script using Predis with a simple loop to add records. I also created a second script that does a similar thing, only on a MySQL table (InnoDB) using PHP's MySQLi.
I ran a 10k loop, a ... | Comparing predis to mysqli is inappropriate
the mysqli extension - is an extension whereas predis is a php-client library. I.e. whereas mysqli is compiled code, predis is just plain php - extensions are faster.
A benchmark of the kind shown in the question primarily shows the performance loss of PHP code versus an exte... | Redis | 13,126,431 | 24 |
I have been using Dalli until now for caching and today I came across Redis -Store.
I am wondering should I switch to redisstore. My app already uses redis for certain stuff so I have a redis server which is quite big(in terms of resources) and I also have another memcached server. So if I where to switch to redis-sto... | Redis can be used as a cache or as a permanent store, but if you try to mix both, you can end up having "interesting issues".
When you have memcached, yo have a maximum amount of memory for the process, so when memcached gets full it will automatically remove the least recently used entries to make room for the new ent... | Redis | 11,076,902 | 24 |
When using redis, it gives me the error:
ERR command not allowed when used memory > 'maxmemory'
The info command reveals:
redis 127.0.0.1:6379> info
redis_version:2.4.10
redis_git_sha1:00000000
redis_git_dirty:0
arch_bits:64
multiplexing_api:kqueue
gcc_version:4.2.1
process_id:1881
uptime_in_seconds:116
uptime_in_days... | This message is returned when maxmemory limit has been reached.
You can check what the current limit is by using the following command:
redis 127.0.0.1:6379> config get maxmemory
1) "maxmemory"
2) "128000000"
The result is in bytes.
Please note an empty Redis instance uses about 710KB of memory (on Linux), so if you p... | Redis | 9,987,832 | 24 |
Eventhough redis and message queueing software are usually used for different purposes, I would like to ask pros and cons of using redis for the following use case:
group of event collectors write incoming messages as key/value . consumers fetch and delete processed keys
load starting from 100k msg/s and going beyond ... | Given your requirements I would try Redis. It will perform better than other solutions and give you much finer grained control over the persistence characteristics. Depending on the language you're using you may be able to use a sharded Redis cluster (you need Redis bindings that support consistent hashing -- not all... | Redis | 7,506,118 | 23 |
Production environment is on Azure, using Redis Cache Standard 2.5GB.
Example 1
System.Web.HttpUnhandledException (0x80004005): Exception of type
'System.Web.HttpUnhandledException' was thrown. --->
StackExchange.Redis.RedisTimeoutException: Timeout performing SETNX
User.313123, inst: 49, mgr: Inactive, err: nev... | There are 3 scenarios that can cause timeouts, and it is hard to know which is in play:
the library is tripping over; in particular, there are known issues relating to the TLS implementation and how we handle the read loop in the v1.* version of the library - something that we have invested a lot of time working on fo... | Redis | 51,651,796 | 23 |
1167:M 26 Apr 13:00:34.666 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
1167:M 26 Apr 13:00:34.667 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
1167:M 26 Apr 13:00:34.667 # Current maximum open files is 4096. maxclients has been reduc... | Well, it's a bit late for this post, but since I just spent a lot of time(the whole night) to configure a new redis server 3.0.6 on ubuntu 16.04. I think I should just write down how I do it so others don't have to waste their time...
For a newly installed redis server, you are probably going to see the following issue... | Redis | 36,880,321 | 23 |
I have an ASP.NET MVC application that runs on server A and some web services that run on server B. I have implemented real-time notifications for which I have used SignalR on server A. But now I need server B to also be able to send messages to a View served from server A (the main web application). Hence, I am trying... | Backplane distributes messages between servers.
GlobalHost.DependencyResolver.UseRedis("localhost", 6379, string.Empty, "abc");
Here, abc is the redis channel, that means whichever server is connected to redis server with this channel, they will share messages. SignalR channel (group) is different than Redis channel. ... | Redis | 36,161,600 | 23 |
I have a web application using Django and i am using Celery for some asynchronous tasks processing.
For Celery, i am using Rabbitmq as a broker, and Redis as a result backend.
Rabbitmq and Redis are running on the same Ubuntu 14.04 server hosted on a local virtual machine.
Celery workers are running on remote machines ... | My guess is that your problem is in the password.
Your password has @ in it, which could be interpreted as a divider between the user:pass and the host section.
The workers stay in pending because they could not connect to the broker correctly.
From celery's documentation
http://docs.celeryproject.org/en/latest/usergui... | Redis | 35,539,778 | 23 |
I was using redis and jedis for quite some time and never needed the SCAN commands so far. Now however I need to use the SCAN commands, particularly hscan. I understand how it works on the redis level, but the jedis Java wrapper side is confusing to me. There are ScanResults and ScanParameter classes flowing around and... | In the good tradition of answering own questions, here is what I found out:
String key = "THEKEY";
ScanParams scanParams = new ScanParams().count(100);
String cur = redis.clients.jedis.ScanParams.SCAN_POINTER_START;
boolean cycleIsFinished = false;
while(!cycleIsFinished) {
ScanResult<Entry<String, String>> scanResu... | Redis | 33,842,026 | 23 |
I have used StackExchange.Redis for c# redis cache.
cache.StringSet("Key1", CustomerObject);
but I want to store data like
cache.StringSet("Key1", ListOfCustomer);
so that one key has all Customer List stored and it is easy to
search,group,filter customer Data also inside that List
Answers are welcome using Serv... | If you use Stackechange.Redis, you can use the List methods on its API.
Here is a naive implementation of IList using a redis list to store the items.
Hopefully it can help you to understand some of the list API methods:
public class RedisList<T> : IList<T>
{
private static ConnectionMultiplexer _cnn;
private s... | Redis | 31,955,977 | 23 |
Following is Jedis documentation directly copied from jedis github page:
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
JedisShardInfo si = new JedisShardInfo("localhost", 6379);
si.setPassword("foobared");
shards.add(si);
si = new JedisShardInfo("localhost", 6380);
si.setPassword("foobared");
shards.ad... | I think it doesn't directly support your case. RedisTemplate offers a high-level abstraction for Redis interactions.
While RedisConnection offers low level methods that accept and return binary values (byte arrays).
See: Working with Objects through RedisTemplate
| Redis | 29,616,706 | 23 |
I am using django-rq to handle some long-running tasks on my django site. These tasks trip the 180 second timeout of the (I assume) rqworker:
JobTimeoutException: Job exceeded maximum timeout value (180 seconds).
How can I increase this timeout value? I've tried adding --timeout 360 to the rqworker command but this ... | This seems to be the right way to approach the problem.
queue = django_rq.get_queue('default')
queue.enqueue(populate_trends, args=(self,), timeout=500)
If you need to pass kwargs,
queue = django_rq.get_queue('default')
queue.enqueue(populate_trends, args=(self,), kwargs={'x': 1,}, timeout=500)
Thanks to the selwin... | Redis | 15,445,036 | 23 |
I was reading Redis documentation, and I am most interested in the partitioning feature.
Redis documentation states the following:
Data store or cache? Partitioning when using Redis ad a data store or
cache is conceptually the same, however there is a huge difference.
While when Redis is used as a data store you n... | [Update] Redis Cluster was released in Redis 3.0.0 on 1 Apr 2015.
Redis cluster is currently in active development. See this article from Redis author: Antirez.
So I can pause other incremental improvements for a bit to focus on Redis Cluster. Basically my plan is to work mostly to cluster as long as it does not reach... | Redis | 14,941,897 | 23 |
I have a model class that caches data in redis. The first time I call a method on the model, it computes a JSON/Hash value and stores it in Redis. Under certain circumstances I 'flush' that data and it gets recomputed on the next call.
Here's the code snippet similar to the one I use to store the data in Redis:
def cac... | I like to have redis running while the tests are running. Redis, unlike e.g. postgres, is extremely fast and doesn't slow down test run time noticeably.
Just make sure you call REDIS.flush in a before(:each) block, or the corresponding cucumber hook.
You can test data_to_cache independently of redis, but unless you can... | Redis | 10,501,461 | 23 |
Premise
Hi,
I received multiple reports from a Redis user that experienced server crashes, using a Redis stable release (latest, 2.4.6). The bug is strange since the user is not doing esoteric things, just working a lot with the sorted set type, and only with the ZADD, ZREM, and ZREVRANK commands. However it is strange... | I think I can answer my own question now...
basically this is what happens. zslGetRank() is called by zrankGenericCommand() with first argument into %rdi register. However later this function will use the %rdi register to set an object (and indeed the %rdi register is set to an object that is valid):
(gdb) print *(robj... | Redis | 8,911,883 | 23 |
I am using nowjs and node_redis. I am trying to create something very simple. But so far, the tutorial have left me blank because they only do console.log().
//REDIS
var redis = require("redis"),
client = redis.createClient();
client.on("error", function (err) {
console.log("Error "+ err);
});
client.set("car... | You are trying to use an async library in a sync way. This is the right way:
//REDIS
var redis = require("redis"),
client = redis.createClient();
client.on("error", function (err) {
console.log("Error "+ err);
});
client.set("card", "apple", function(err) {
if (err) throw err;
});
everyone.now.signalShow... | Redis | 6,924,639 | 23 |
So I've already read this post about there not being an MGET analog for Redis hashes. One of the answers said to use MULTI/EXEC to do the operation in bulk, and that does work for lists and regular keys, but not for hashes, unfortunately. Right now, however, I'm doing a call over the wire for every single hash I want t... | The most efficient way would be using a pipeline.
Assuming you want everything for a given key and know all the keys already:
import redis
r = redis.Redis(host='localhost', port=6379, db=0)
p = r.pipeline()
for key in keys:
p.hgetall(key)
for h in p.execute():
print h
More information about pipelines can be ... | Redis | 4,929,202 | 23 |
I'm a newcomer to Redis and I'm looking for some specific help around sets. To give some background: I'm building a web-app which consists of a large number of card decks which each have a set of individual cards with unique ids. I want users to have a set of 5 cards drawn for them at random from a specific deck.
My pl... | redis> sadd mydeck 1
(integer) 1
redis> sadd mydeck 2
(integer) 1
redis> sadd mydeck 3
(integer) 1
redis> smembers mydeck
1) "1"
2) "2"
3) "3"
redis> sunionstore tempdeck mydeck
(integer) 3
redis> smembers mydeck
1) "1"
2) "2"
3) "3"
redis> smembers tempdeck
1) "1"
2) "2"
3) "3"
Have fun with Redis!
Salvatore
| Redis | 4,474,770 | 23 |
Application consists of:
- Django
- Redis
- Celery
- Docker
- Postgres
Before merging the project into docker, everything was working smooth and fine, but once it has been moved into containers, something wrong started to happen.
At first it starts perfectly fine, but after a while I do receive folowing error:
celery-b... | Another solution (taken from https://stackoverflow.com/a/17674248/39296) is to use --pidfile= (with no path) to not create a pidfile at all. Same effect as Siyu's answer above.
| Redis | 53,521,959 | 22 |
I am trying to setup a docker-compose file that is intended to replace a single Docker container solution that runs several processes (RQ worker, RQ dashboard and a Flask application) with Supervisor.
The host system is a Debian 8 Linux and my docker-compose.yml looks like this (I deleted all other entries to reduce er... | In your code localhost from rq-worker1 is rq-worker1 itself, not redis and you can't reach redis:6379 by connect to localhost from rq-worker1. But by default redis and rq-worker1 are in the same network and you can use service name as a domain name in that network.
It means, that you can connect to redis service from r... | Redis | 41,302,791 | 22 |
My application currently use Spring Session together with Redis as the backend.
I searched into the official documentation for Spring Session but was not able to find what the default session timeout is when using that module. Also I am not sure how to change that default timeout if necessary.
Can someone please advise... | The easiest way to configure session timeout when using redis repository is
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 60)
OR @EnableRedissonHttpSession(maxInactiveIntervalInSeconds = 1200) if redisson dependency is there.
The session expires when it is no longer available in the repository.
Timeout can be... | Redis | 32,501,541 | 22 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.