# Collection of code snippets by Arne Vajhøj 
# (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
from pyignite import Client

cli = Client()
cli.connect('localhost', 10800)
cache = cli.get_or_create_cache('functional_cache')

# basic put, get and remove
cache.put('v', 123)
print(cache.get('v'))
cache.remove_keys('v')
print(cache.get('v'))
cache.put('v', 123)
print(cache.get('v'))

# persistence
counter = cache.get('counter')
if(counter == None):
    counter = 0;
counter = counter + 1
print(counter)                                                                       
cache.put('counter', counter)

# list all not supported using thin

# listener not supported using thin

cli.close()
