|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ApplicationServer.Caching;
namespace AppFabricDataCache
{
class Program
{
static void Main(string[] args)
{
// DataCacheFactory will use settings from app.config
using (DataCacheFactory dataCacheFactory = new DataCacheFactory())
{
// Get a default cache client
DataCache dataCache = dataCacheFactory.GetDefaultCache();
// Create a new person
Person nPerson = new Person("Panagiotis", "Kefalidis");
Console.WriteLine(string.Format("Currently in your account: {0}", nPerson.GetBalance()));
// Deposit some money
nPerson.DepositMoney(100);
Console.WriteLine(string.Format("Currently in your account after deposit: {0}", nPerson.GetBalance()));
// Put that object into the cache
dataCache.Put(nPerson.GetFullName(), nPerson);
// Remove some money
nPerson.WithdrawMoney(50);
// Get the cached object back from the cache
Person cachedPerson = (Person)dataCache.Get(nPerson.GetFullName());
// How much money do we have now?
Console.WriteLine(string.Format("Currently in your cached account after withdraw: {0}", cachedPerson.GetBalance()));
// How much money we REALLY have now?
Console.WriteLine(string.Format("Currently in your account after withdraw: {0}", nPerson.GetBalance()));
// Update the cache with latest information
dataCache.Put(nPerson.GetFullName(), nPerson);
}
Console.ReadKey();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Panagiotis is a Software Development Consultant & Architect and Trainer. He has been a speaker at domestic and international events such TechEd and ITProDevConnections, delivering trainings and consulting on cloud computing and the Windows Azure Platform for almost 3 years. He also has experience with other cloud platforms like AWS, Google Gears and others. He's a supporter of the EuroCloud movement, likes Pizza, Sushi and fast cars. Born and raised in Greece but currently living and working at Belgium for Devoteam BE.
Panagiotis is a Windows Azure MVP.