• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
  • License
    Other
  • Created over 13 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

titanium-cache provides caching for Appcelerator’s Titanium Mobile applications.

titanium-cache

titanium-cache provides caching for Appcelerator’s Titanium Mobile applications.

How it works

Titanium Mobile translates your hard won JavaScript skills into native applications that perform and look just like they were written in Objective-C (iPhone and iPad) or Java (Android).

Mobile applications usually perform requests over the Internet to get data from APIs, and they can get very slow depending on the number of API calls you need to make.

titanium-cache provides caching capabilities for Titanium Mobile applications using SQLite local storage, so you can improve the performance of your mobile applications.

How to use in your projects

Just copy the cache.js to your project and include it (only once) from your app.js file using:

Ti.include('cache.js');

After that, the caching functions will be available under Ti.App.Cache.*, just like Titanium native functions.

1. Get item from cache

var cached_obj = Ti.App.Cache.get('my_data');

2. Add item to cache

You can cache strings or JavaScript native objects only. Images caching is not supported at this moment.

// if you do not specify, the default cache time is 5 minutes
var my_javascript_object = { property: 'value' };
Ti.App.Cache.put('my_data', my_javascript_object);
// cache another object (a xml document) for 1 hour
// (you can specify different cache expiration times then 5 minutes)
Ti.App.Cache.put('another_data', xml_document, 3600);

3. Delete item from cache

Ti.App.Cache.del('my_data');

4. Disabling cache for development

If you need to disable cache (useful while you are developing the application), just go to cache.js file and change the DISABLE variable value to true.

How to run the tests

titanium-cache tests are located in the cache_tests.js file.

These tests are written in Jasmine using titanium-jasmine as the test runner.

For more info on how to run these tests in your application, please refer to titanium-jasmine documentation on GitHub.

More info

If you want to see how I use titanium-cache on a real production project, please take a look at Yahoo! Meme’s source code on GitHub.

If you have any other questions, please contact me through Twitter or e-mail.

License

titanium-cache is licensed under Apache Public License (Version 2). See LICENSE for more details.

Developed by Guilherme Chapiewski with contributions from Robb Shecter.

More Repositories

1

simple-db-migrate

simple-db-migrate is a generic database migration tool inpired on Rails migrations.
Python
197
star
2

titanium-jasmine

titanium-jasmine provides testing for Appcelerator’s Titanium Mobile applications using Pivotal’s Jasmine as the core testing framework.
JavaScript
190
star
3

correios-api

API Ruby e REST para obter informações de encomendas/Sedex dos Correios.
Ruby
60
star
4

fluent-mail-api

Fluent Mail API is a simple Java API that uses Sun's JavaMail API and a fluent interface/internal DSL to send e-mail messages.
Java
38
star
5

yql-ios

Objective-C library that provides YQL connectivity for iOS applications.
Objective-C
37
star
6

correios-api-py

API Python para obter informações de encomendas/Sedex dos Correios.
29
star
7

git2svn

Migrate a Git repository to SVN preserving history (yes, you read it right)
Shell
25
star
8

meme-py

Python client for Yahoo! Meme
Python
16
star
9

django-supermodels

Model extensions for Django to provide dynamic finders.
Python
10
star
10

pyccuracy-tmbundle

Pyccuracy TextMate bundle.
8
star
11

jquery-meme

JQuery plugin for Yahoo! Meme
JavaScript
6
star
12

correios-macosx-widget

Widget do Dashboard (Mac OS X) para rastreamento de encomendas dos Correios.
JavaScript
5
star
13

cruzalinhas-ios

CruzaLinhas para iOS.
JavaScript
3
star
14

git-repository-extractor

Extracts subdirectories of a Git repository into smaller and separate repositories.
Shell
3
star
15

youtube-yql-api

Google App Engine service used as the backend for YouTube YQL tables.
Python
2
star
16

meme-ios-backend

Backend application for Yahoo! Meme iOS apps.
Python
2
star
17

ynspector

ynspector inspects a given directory and runs a command everytime a file is changed.
2
star
18

pyccuracy-presentation

Pyccuracy presentation stuff.
Ruby
2
star