Package io.toro.martini.redis
Class RedisGloopMethods
- java.lang.Object
-
- io.toro.martini.redis.RedisBaseMethods
-
- io.toro.martini.redis.RedisGloopMethods
-
public class RedisGloopMethods extends io.toro.martini.redis.RedisBaseMethods
This class is used to read and write Gloop Models to Redis databases.
-
-
Constructor Summary
Constructors Constructor Description RedisGloopMethods(io.toro.martini.database.DataSourceManager dataSourceManager)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static GloopModel
getKeyScanCursorAsGloopCursor(String connectionName, KeyScanCursor keyScanCursor, GloopExecutionContext context)
Gets a KeyScanCursor as a Gloop Cursor.static GloopModel
gloopGet(String connectionName, Object key, GloopExecutionContext context)
Single Gloop model get.static Future<GloopModel>
gloopGetAsync(String connectionName, Object key, GloopExecutionContext context)
Asynchronous single Gloop model get.static String
gloopSet(String connectionName, Object key, GloopModel value, GloopExecutionContext context)
Single Gloop model set.static Future<String>
gloopSetAsync(String connectionName, Object key, GloopModel value, GloopExecutionContext context)
Asynchronous single Gloop model set.static GloopModel
openRedisInputCursor(String connectionName, GloopModel scanArgs, GloopExecutionContext context)
Opens a cursor that can be used to bulk-write data to a redis database.static GloopModel
openRedisOutputCursor(String connectionName, int batchSize, int timeout, GloopExecutionContext context)
Opens a cursor that can be used to bulk-write data to a redis database.
-
-
-
Constructor Detail
-
RedisGloopMethods
@Autowired RedisGloopMethods(io.toro.martini.database.DataSourceManager dataSourceManager)
-
-
Method Detail
-
gloopGetAsync
@GloopParameter(name="redisFutureGloopGetOutput") public static Future<GloopModel> gloopGetAsync(@GloopParameter(allowNull=false) String connectionName, @GloopParameter(allowNull=false) Object key, GloopExecutionContext context)
Asynchronous single Gloop model get.- Parameters:
connectionName
- The Martini Runtime Redis connection pool namekey
- the key of the record- Returns:
- The value as a gloop model (if it exists)
-
gloopGet
@GloopParameter(name="redisGloopGetOutput") public static GloopModel gloopGet(@GloopParameter(allowNull=false) String connectionName, @GloopParameter(allowNull=false) Object key, GloopExecutionContext context)
Single Gloop model get.- Parameters:
connectionName
- The Martini Runtime Redis connection pool namekey
- the key of the record- Returns:
- String simple-string-reply
OK
ifSET
was executed correctly.
-
gloopSetAsync
@GloopParameter(name="redisFutureGloopSetOutput") public static Future<String> gloopSetAsync(@GloopParameter(allowNull=false) String connectionName, @GloopParameter(allowNull=false) Object key, @GloopParameter(allowNull=false) GloopModel value, GloopExecutionContext context)
Asynchronous single Gloop model set.- Parameters:
connectionName
- The Martini Runtime Redis connection pool namekey
- the key of the recordvalue
- the Gloop Object which is the value- Returns:
- String simple-string-reply
OK
ifSET
was executed correctly.
-
gloopSet
@GloopParameter(name="redisGloopSetOutput") public static String gloopSet(@GloopParameter(allowNull=false) String connectionName, @GloopParameter(allowNull=false) Object key, @GloopParameter(allowNull=false) GloopModel value, GloopExecutionContext context)
Single Gloop model set.- Parameters:
connectionName
- The Martini Runtime Redis connection pool namekey
- the key of the recordvalue
- the Gloop Object which is the value- Returns:
- String simple-string-reply
OK
ifSET
was executed correctly.
-
openRedisOutputCursor
@GloopObjectParameter("output{\n redisOutputCursor[]{\n redisKey\n redisValue:object\n }\n}") public static GloopModel openRedisOutputCursor(@GloopParameter(allowNull=false) String connectionName, @GloopParameter(allowNull=false,defaultValue="1000") int batchSize, @GloopParameter(allowNull=false,defaultValue="5") int timeout, GloopExecutionContext context)
Opens a cursor that can be used to bulk-write data to a redis database. Gloop Models are written as json, whereas other objects as written using the output of theObject.toString()
method- Parameters:
connectionName
- The Martini Runtime Redis connection pool namebatchSize
- How many records to queue before writing them to the databasetimeout
- How long to wait (in seconds) before throwing an exception while writing a batch to the database
-
openRedisInputCursor
@GloopObjectParameter("output{\n redisKeyValues[]{\n key:object\n value:object\n }\n}") public static GloopModel openRedisInputCursor(@GloopParameter(allowNull=false) String connectionName, @GloopObjectParameter("scanArgs{\n limit:long:Limit the scan by count:false\n match::Set the match filter:false\n}\n") GloopModel scanArgs, GloopExecutionContext context)
Opens a cursor that can be used to bulk-write data to a redis database. Gloop Models are written as json, whereas other objects as written using the output of theObject.toString()
method- Parameters:
connectionName
- The Martini Runtime Redis connection pool namescanArgs
- Scan arguments
-
getKeyScanCursorAsGloopCursor
@GloopObjectParameter("output{\n redisKeys[]:object\n}") public static GloopModel getKeyScanCursorAsGloopCursor(@GloopParameter(allowNull=false) String connectionName, @GloopParameter(allowNull=false) KeyScanCursor keyScanCursor, GloopExecutionContext context)
Gets a KeyScanCursor as a Gloop Cursor. If you want to iterate over a redis database, use theRedisKeyMethods#scan(String)
method or any other scan method to get the initial KeyScanCursor. Then call this (with the same connection name) to convert the Redis KeyScanCursor to a GloopCursor- Parameters:
keyScanCursor
- The KeyScanCursor to get the keys from- Returns:
- keys of the cursor as a Gloop Cursor
-
-