Drathier
Drathier

Reputation: 14539

Using Google App Engine as simple key/value store

I want something functionally equivalent to a string->string key-value store in app engine ndb, similar to Couchbase. I don't want to model anything. What options do I have?

Upvotes: 2

Views: 151

Answers (1)

Greg
Greg

Reputation: 10360

Something like this?

class KVStore(ndb.Model):
  v = ndb.TextProperty()

  @classmethod
  def get(cls, k):
    e = cls.get_by_id(k)
    return e.v if e else None

  @classmethod
  def set(cls, k, v):
    e = cls(id=k, v=v)
    e.put()

Upvotes: 2

Related Questions