opened
superkhau
username_0
KeyValue memory connector RI.
Add KeyValue memory connector
issue
created
superkhau
username_0
/cc @username_1
comment
created
bajtos
username_1
@username_0 I added basic implementation of `get` and `set` methods together with tests.

@raymondfeng @username_2 please review if this implementation of KeyValue API & connector is going in the right direction.
comment
created
bajtos
username_1
@raymondfeng @username_2 @username_0 I pushed few more commits implemeting `set(key, value, ttl)` and `expire(key, ttl)`. PTAL
comment
created
bajtos
username_1
At the moment, this pull request contains all that's needed for the first cut of this new feature IMO.

Models attached to a kv-memory datasource will get the following *static* methods:

```js
Color.set(key, value);
Color.set(key, value, ttl);
Color.set(key, value, { ttl: ttl });

Color.get(key);

Color.expire(key, ttl);
```

The proposal in strongloop/loopback#2525 describes prototype methods too. In my view, they are a syntactic sugar that's out of scope of this initial pull request, and should be implemented in the next iteration (e.g. right after this patch is landed).

Another missing item is `Color.ttl(key)`, I am not sure how important that method is? If we think it should be part of the initial release, then we can implement it in the next iteration too.

@raymondfeng @username_2 @username_0 please review
comment
created
superkhau
username_0
LGTM, nice work.
comment
created
ritch
username_2
It is important.
comment
created
superkhau
username_0
@username_1 Added TTL, review please.
comment
created
bajtos
username_1
FWIW, `ttl` method is not available in all key-value stores. For example, memcached does not support it according to [SO](http://stackoverflow.com/questions/5329431/memcache-get-key-expiry-times) and [client API docs](https://www.npmjs.com/package/memcached#api).

I am fine with including `ttl` in the first release, but please move it to a new standalone pull request, so that we can land this one. @username_0 

/cc @username_2
comment
created
superkhau
username_0
@username_1 TTL code moved to https://github.com/strongloop/loopback-datasource-juggler/pull/1030, also removed TTL code from this PR.
comment
created
bajtos
username_1
Thank you! I'll clean up the commit history and get this landed to both `master` and `2.x`.
comment
created
bajtos
username_1
@slnode test please
comment