Key-value Template
The key value is a bridge between the entity and the key-value database.
KeyValueTemplate
KeyValueTemplateThe KeyValueTemplate is the column template to synchronous tasks. It has three components:
The KeyValueTemplate is responsible for persistency of an entity in a key-value database. It is composed basically for three components.
KeyValueEntityConverter: That converts an entity to communication API, e.g., The Person to KeyValueEntity.
BucketManager: The Diana column key-value entity manager.
KeyValueWorkflow: The workflow to update and save methods.
KeyValueTemplate template = null;
User user = new User();
user.setNickname("ada");
user.setAge(10);
user.setName("Ada Lovelace");
List<User> users = Collections.singletonList(user);
template.put(user);
template.put(users);
Optional<Person> ada = template.get("ada", Person.class);
Iterable<Person> usersFound = template.get(Collections.singletonList("ada"), Person.class);To use a key-value template just follows the CDI style and put an @Inject on the field.
The next step is to produce a BucketManager:
To work with more than one key-value Template, there are two approaches:
1) Using qualifieres:
2) Using the KeyValueTemplateProducer class
Last updated