public class InMemoryFeatureStore extends java.lang.Object implements FeatureStore, DiagnosticDescription
HashMap
. This is the default implementation of FeatureStore
.Constructor and Description |
---|
InMemoryFeatureStore() |
Modifier and Type | Method and Description |
---|---|
<T extends VersionedData> |
all(VersionedDataKind<T> kind)
Returns a
Map of all associated objects of a given kind. |
void |
close()
Does nothing; this class does not have any resources to release
|
<T extends VersionedData> |
delete(VersionedDataKind<T> kind,
java.lang.String key,
int version)
Deletes the object associated with the specified key, if it exists and its version
is less than or equal to the specified version.
|
LDValue |
describeConfiguration(LDConfig config)
Used internally by the SDK to inspect the configuration.
|
<T extends VersionedData> |
get(VersionedDataKind<T> kind,
java.lang.String key)
Returns the object to which the specified key is mapped, or
null if the key is not associated or the associated object has
been deleted.
|
void |
init(java.util.Map<VersionedDataKind<?>,java.util.Map<java.lang.String,? extends VersionedData>> allData)
Initializes (or re-initializes) the store with the specified set of objects.
|
boolean |
initialized()
Returns true if this store has been initialized.
|
<T extends VersionedData> |
upsert(VersionedDataKind<T> kind,
T item)
Update or insert the object associated with the specified key, if its version
is less than or equal to the version specified in the argument object.
|
public <T extends VersionedData> T get(VersionedDataKind<T> kind, java.lang.String key)
FeatureStore
get
in interface FeatureStore
T
- class of the object that will be returnedkind
- the kind of object to getkey
- the key whose associated object is to be returnedpublic <T extends VersionedData> java.util.Map<java.lang.String,T> all(VersionedDataKind<T> kind)
FeatureStore
Map
of all associated objects of a given kind.all
in interface FeatureStore
T
- class of the objects that will be returned in the mapkind
- the kind of objects to getpublic void init(java.util.Map<VersionedDataKind<?>,java.util.Map<java.lang.String,? extends VersionedData>> allData)
FeatureStore
If possible, the store should update the entire data set atomically. If that is not possible, it should iterate through the outer map and then the inner map in the order provided (the SDK will use a Map subclass that has a defined ordering), storing each item, and then delete any leftover items at the very end.
The store should not attempt to modify any of the Maps, and if it needs to retain the data in memory it should copy the Maps.
init
in interface FeatureStore
allData
- all objects to be storedpublic <T extends VersionedData> void delete(VersionedDataKind<T> kind, java.lang.String key, int version)
FeatureStore
delete
in interface FeatureStore
T
- class of the object to be deletedkind
- the kind of object to deletekey
- the key of the object to be deletedversion
- the version for the delete operationpublic <T extends VersionedData> void upsert(VersionedDataKind<T> kind, T item)
FeatureStore
upsert
in interface FeatureStore
T
- class of the object to be updatedkind
- the kind of object to updateitem
- the object to update or insertpublic boolean initialized()
FeatureStore
initialized
in interface FeatureStore
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
- will never happenpublic LDValue describeConfiguration(LDConfig config)
DiagnosticDescription
describeConfiguration
in interface DiagnosticDescription
config
- the full configuration, in case this component depends on properties outside itselfLDValue
or null