Code Monkey home page Code Monkey logo

realm.keyvaluestorage's Introduction

Realm

Realm is a mobile database that runs directly inside phones, tablets or wearables.

This library extends the Realm mobile database to provide convenient key/value based storage. This is useful in situations where you have one-off or single pieces of data like:

  • user information (name, last login timestamp, pin code, etc.)
  • settings/preferences
  • temporary data

Getting Started

This library is a lightweight wrapper around Realm so be sure to check out the official Realm .NET repository for documentation and examples on advanced querying and usage of Realm.

// Get a KeyValueRealm instance
var realm = KeyValueRealm.GetInstance();

// Save some values
realm.Set("First Name", "John");
realm.Set("PinCode", 1234);

// Retrieve the pin code strongly typed as an integer
var pinCode = realm.Get<int>("PinCode"); // pinCode == 1234

// Remove the first name
realm.Remove("First Name");
var firstName = realm.Get("firstName"); // firstName == null

// Set a key named "Married" that expires two days from now
realm.Set("Married", true, DateTimeOffset.Now.AddDays(2));

KeyValueRealm

KeyValueRealm is a lightweight wrapper around a standard Realm object providing convenience methods specifically optimized for working with key/value based storage.

You call KeyValueRealm.GetInstance() to retrieve an instance, optionally passing the same types of parameters as you would when calling Realm.GetInstance() normally. You have complete control of the underlying Realm. This class just makes it easier to work with keys and values.

KeyValueItem

A KeyValueItem is a Realm object that contains Key, Value, and ExpiresOn fields. This is the main object you interact with and use with a KeyValueRealm to save the item. There are convenience methods as shown in the Getting Started section above that handle creating and modifying these objects for you.

Expiring Keys

Keys can be set to expire after a specified time. If a key is queried and it is after it's expiration, it will be removed from the database and null will be returned.

License

Realm Key Value Storage is licensed the same as the Realm project. Realm Key Value Storage is published under the Apache 2.0 license.

realm.keyvaluestorage's People

Contributors

adamfisher avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

braincreator

realm.keyvaluestorage's Issues

iOS null exception

Hi,

I am getting exception in iOS ( The class KeyValueItem is not in the limited set of classes for this realm)

My code is:

var realm = KeyValueRealm.GetInstance();
if(realm != null) {
	realm.Set("test", "tokenData");
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.