Generate new key inside EVALSHA - lua

Documentation states that keys must be passed explicitly, so if using Redis cluster, the command can be forwarded to the appropriate node.
However, does this apply to new keys as well? For example, if I have a script to register a new entity, and such script is creating dynamically a totally new key composed by the result of INCR and a literal, would it be a problem for Redis cluster?
The alternative would be to call to INCR in a separate operation and pass the key to the script as KEY[1].

If you're careful to ensure that your new key is hashed to the same server as your other keys, I think you'll be fine.
That is, the important thing with Cluster is not just to declare your keys up front, but to make sure that all the keys your script operates on are located on the same server. You can do that with your keys by using hash tags. If you construct your new key in such a way that it hashes to the same slot as your others, I think it will work fine.

Related

Which relay objects must implement `Node`?

https://facebook.github.io/relay/graphql/objectidentification.htm is very clear around what Node is and how it behaves, but it doesn't specify which objects must implement it, or what the consequences are if your object doesn't implement it. Is there a set of features that don't work? Are such objects completely ignored? Not all objects in the existing spec (e.g. pageInfo) implement it, so it's clearly not universally required, but pageInfo is somewhat of a special case.
Another way of thinking about the Node interface is that objects that implement it are refetchable. Refetchability effectively means that an object has an ID that I can use to identify the object and retrieve it; by convention, these IDs will usually be opaque, but will contain type information and an identifier within that type (eg. a Base-64 encoding of a string like "Account:1234").
Relay will leverage refetchability in two ways:
Under a process known as "diffing", if you already have some data for an object identified by ID QWNjb3VudDoxMjM0 (say, the name and address fields), and you then navigate to a view where we show some additional fields (location, createdAt) then Relay can make a minimal query that "refetches" the node but only requests the missing fields.
Relatedly, Relay will diff connections and will make use of the Node interface to fill in missing data on those (example: through some combination of navigation you might have full information for some items in a view, but need to fill in location for some items within the range, or you might modify an item in a connection via a mutation). So, in basic pagination, Relay will often end up making a first + after query to extend a connection, but if you inspect its network traffic in a real app you will also see that it makes node queries for items within connections.
So yes, you're right that pageInfo doesn't implement Node, and it wouldn't really make sense for it to do so.

Can I directly store a type in an ADOJobStore in Quartz.Net

I would like to execute a job that requires that I save a type in the JobDataMap. This will later be used along with the ID of an entity to rehydrate the entity so the job can use it.
I know I could get the AssemblyQualifiedName of the type and store that, then use GetType() in the job, but before I go down that path, I thought I'd see if quartz just does this for me.
If I put a type in the JobDataMap, will it serialize and deserialize when I access the property later?
Sure it will. You can use the JobDataMap indexer to store arbitrary data. Type instances are quite safe, but you need to be extra careful about versions (using only assembly qualified name removes this problem), namespaces and public keys.
If there were a slight possibility that the type might change after persisting I would recommended using a 'meta name' like 'BackupJobHelperType' that you would then resolve to the actual type. Generelly always prefer simple serialization safe types over own types, if possible set quartz.jobStore.useProperties to true which will enforce string key and values.
You can save the info when building the job and it will be available when the job starts.

writing a JBehave story

This question isn't about REST, but about using the returned value from an invocation made in #When in the subsequent #Then.
I am looking at using JBehave to test some calls to a REST api. First there is a post to create the user
When I create a user with name Charles Darwin
As I understand REST, and this is what the Atom api does, the id is returned in the location header, e.g. /user/22. So then I want to assert something about the response.
Then user was created with a valid Id
I can do this by creating a member variable in the Steps class and storing the response there, and I have used this approach before, but is this the correct way?
Yes. One needs to store data that can be asserted on in your #Then methods. The simplest way to do this is to have a member variable - but that means that your #When/#Then need to be in the same Steps class. Another way to do it is to have a shared data object that all your Steps use and you can then set it in one method and get it in another. If you just want something generic, you can do a Map<String,? extends Object> as your generic data object. And then if you run with multiple threads, then wrap the data object in a ThreadLocal.
That's what I've seen - and the data object should be setup/cleared with a #BeforeScenario/#AfterScenario method.

Symfony2 entity dependencies/app parameters

I'm pretty new to Symfony2 and I'm trying to get to grips with how and when to pass dependencies / app parameters and have got into a muddle with how to insert parameters into an entity.
The situation is that I have an entity which will contain strings of uploaded file names and I want to pass through the parameters of the directory location (where the uploaded file will be stored) which I have set in app/config.yml. Which is basically similar to http://symfony.com/doc/2.0/cookbook/doctrine/file_uploads.html but with the paths defined in app/config.yml rather than hard coded into the entity.
First off I thought this could be done via the constructor, but this only seems fine for new objects and not when they are pulled out the repository? (as the constructor is not called then) so I don't know how you're supposed to pass the dependencies to the entites.
Any guidance much appreciated.
I think this problem should be solved by adding a listener for onLoad (and maybe onPersist, not sure) events.
In the entity add a setUploadPath($path) method, which you will call with the listener.
In order to actually have the path parameter in the listener you can pass it as constructor argument when setting up the listener service.

Getting the key of a directory in the registry

How to get the key of a especific directory in the registry of windows XP?
I'm using Delphi
HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags
There are no directories in the registry. The registry contains keys and values. The values have names and data. The keys are like directories, though.
If you want to inspect the contents of a key, you can use the TRegistry class. Set its RootKey property to HKey_Current_User, and use its OpenKeyReadOnly method to open the subkey. Then you can use the various Read methods to read the data of any value.
If you're not sure what the type is of a data entry, you can use the GetDataType orGetDataInfo` methods.
To read a list of all the data entries' names, you can use GetValueNames.
All of those are documented in the help, and now that you know their names, it should be easier for you to find many examples.

Resources