Skip to content

A set of practices to help maintain sanity when building an application that uses Akavache distilled from hard lessons learned.

Notifications You must be signed in to change notification settings

akavache/akavache-design-guidelines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 

Repository files navigation

Akavache Design Guidelines

A set of practices to help maintain sanity when building an application that uses Akavache application distilled from hard lessons learned.

The general rule of thumb with Akavache is to treat it like any other service boundary. Pretend it's like calling a Web API.

Store dumb simple data objects in the cache

Do

// Data Class 
public class RepositoryData
{
    public string Name { get; set; }
    public string Owner { get; set; }
}

// When saving data.

var repoViewModel = GetRepository(name);
var repositoryData = new RepositoryData { Name = repoViewModel.Name, Owner = 
repoViewModel.Owner };

IBlobCache cache = GetCache(...);
cache.InsertObject<RepositoryData>(repositoryData);

// When retrieving
var repoData = await cache.GetObjectAsync<RepositoryData>();
var repoViewModel = new RepositoryViewModel { Name = repoData.Name, 
repoData.Owner };

Don't

Store arbitrary objects graphs:

var repoViewModel = GetRepository(name);
IBlobCache cache = GetCache(...);
cache.InsertObject<RepositoryData>(repoViewModel);

// When retrieving
var repoViewModel = await cache.GetObjectAsync<RepositoryViewModel>();

Better

Akavache should have helper methods for doing this:

var repoViewModel = GetRepository(name);
var repositoryData = repoViewModel.ToCacheable<RepositoryData>();

IBlobCache cache = GetCache(...);
cache.InsertObject<RepositoryData>(repositoryData);

// When retrieving
var repoData = await cache.GetObjectAsync<RepositoryData>();
var repoViewModel = new RepositoryViewModel(repoData);
// OR
var repoViewModel = repoData.ToViewModel<IRepositoryViewModel>();

About

A set of practices to help maintain sanity when building an application that uses Akavache distilled from hard lessons learned.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published