Problem statement
Sessions stored in a HashMap belong to only one web server and disappear when it restarts. Store the sessions in Redis so every server sees the same values.
Requirements
The connected Jedis client, the session key prefix, keyFor(token) and keyBytes(token) are already provided. Your task has seven methods in src/main/java/com/staffcoder/redis/TokenStore.java. Redis strings can hold either text or arbitrary bytes.
- put(token, value) and get(token) store and return the exact text value under the key produced by keyFor(token).
- get(token) returns null when the token has no stored value.
- putBytes(token, value) stores arbitrary bytes without modification, and getBytes(token) returns the exact byte array.
- has(token) returns a boolean that reports both present and absent tokens.
- typeOf(token) returns string for a stored session and none for an absent token.
- remove(tokens) deletes every named token and returns the number of keys that existed.
- A later call to put(token, value) replaces the value already stored for that token.
Sample Usage
get("demo") after storing the text value active
activehas("missing")
falseNote: Refer to the README.md file for detailed implementation requirements.
Sessions stored in a Map belong to only one web server and disappear when it restarts. Store the sessions in Redis so every server sees the same values.
Requirements
The connected Redis client, the session key prefix and keyFor(token) are already provided. Your task has six methods in src/tokenStore.js. Redis strings can hold either text or arbitrary bytes.
- put(token, value) and get(token) store and return the exact text value under the key produced by keyFor(token).
- get(token) returns null when the token has no stored value.
- Binary values passed to put(token, value) are stored without modification, and getBytes(token) returns the exact value as a Buffer.
- has(token) returns a boolean that reports both present and absent tokens.
- typeOf(token) returns string for a stored session and none for an absent token.
- remove(...tokens) deletes every named token and returns the number of keys that existed.
- A later call to put(token, value) replaces the value already stored for that token.
Sample Usage
get("demo") after storing the text value active
activehas("missing")
falseNote: Refer to the README.md file for detailed implementation requirements.
Sessions stored in a dictionary belong to only one web server and disappear when it restarts. Store the sessions in Redis so every server sees the same values.
Requirements
The connected Redis client, the session key prefix and key_for(token) are already provided. Your task has six methods in src/token_store.py. The client returns raw bytes, while the public methods return either text or bytes as described below.
- put(token, value) and get(token) store and return the exact text value under the key produced by key_for(token).
- get(token) returns None when the token has no stored value.
- Binary values passed to put(token, value) are stored without modification, and get_bytes(token) returns the exact value as bytes.
- has(token) returns a bool that reports both present and absent tokens.
- type_of(token) returns string for a stored session and none for an absent token.
- remove(*tokens) deletes every named token and returns the number of keys that existed.
- A later call to put(token, value) replaces the value already stored for that token.
Sample Usage
get("demo") after storing the text value active
activehas("missing")
FalseNote: Refer to the README.md file for detailed implementation requirements.
