Giter Club home page Giter Club logo

angular-cache's People

Contributors

abhijeetkpawar avatar greenkeeperio-bot avatar gulinss avatar headbandno2 avatar jmdobry avatar mmealling avatar pennersr avatar sanderdan avatar stigok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-cache's Issues

Hey yo!

I just overlooked the source and wanna say thank you.

angular-cache is one of the few repos which is well documented and nice coded. I like your coding style since its going in the direction of the angular source.

Keep up the good work man!

PS: If you wanna see what else you could put in your repo, take a look at the component-seed

To see a save naming convention, checkout angular-translate

Peace!

This issue can be closed now. :)

Allow cache to lazy-delete items

When maxAge is specified, the current implementation uses $timeout to actively delete items from the cache. With large caches this could tie up the cpu too much.

Lazy delete means that items aren't deleted until they are requested and have expired (no need for $timeout). This conserves cpu but uses more memory.

I'm not sure which should be the default yet.

Add ability to set global cache defaults in $angularCacheFactoryProvider

In an app module's config() method where service providers are configured, add the ability to configure the $angularCacheFactoryProvider. The first configuration option that will be available will be the ability to configure global defaults for all caches produced by $angularCacheFactory. For example: if I want all of my caches to have a capacity of 1000, I could do:

app.module('myApp', ['jmdobry.angular-cache'])
    .config(function ($angularCacheFactoryProvider) {
        $angularCacheFactoryProvider.setCacheDefaults({
            capacity: 1000
        });
    })
    .run(function ($angularCacheFactory) {
        $angularCacheFactory('newCache').info().capacity; // 1000
    });

README has incorrect examples of time spans

There's several places in the README where you have an example of setting the maxAge option like this:

maxAge: 90000, // Items added to this cache expire after 15 minutes

You are missing a zero. This is actually 1.5 mins, not 15 mins. You do this in several other places with a similar claim that 600000 = 10mins.

1.2.1 (2.0.0 bug fixes)

This branch will only receive the backwards compatible bug fixes that make it into 2.0.0.

Cherry-pick bug fixes for:

Tag versions

Please tag versions so that they can be pinned. Also, it would be nice if the output filenames were not versioned (ie - angular-cache.js / angular-cache.min.js rather than angular-cache-n.n.n.js), so that references don't have to change with an update.

Clarify usage documentation

The usage documentation in the readme needs to clarify that ngAdvancedCache has to be declared as a dependency of the user's Angular module in order to be used.

feature: AngularCache.setOptions()

Allow the configuration of a cache to be updated dynamically.

This way you won't have to destroy a cache and re-create it with new options in order to change the configuration. All of the current items in the cache will stay in the cache.

Any timers will start over beginning at the moment when the related options change.

AngularCache#info(key)

AngularCache#info already exists. This feature is to augment AngularCache#info to accept one argument, the key for an item in the cache. If the item exists in the cache AngularCache#info will return information about the item: when it was added, whether it has expired, etc.

Add option specifying how frequently to check if items have expired (performance)

In aggressive delete mode, this method eliminates a $timeout for every item in the cache and instead uses setInterval to sweep the cache for expired items. Setting this to 60000 for example, has the cache only checking for expired items once a minute, instead of the browser watching a timeout for every item in the cache.

Is it worth it to look into this?

Re-write all unit tests.

After the major refactor of #57 all unit tests need to be re-written (most of them anyway).

  • - $angularCacheFactoryProvider.setCacheDefaults(options)
  • - $angularCacheFactory(cacheId, options)
  • - $angularCacheFactory.get(cacheId)
  • - $angularCacheFactory.removeAll()
  • - $angularCacheFactory.clearAll()
  • - $angularCacheFactory.info()
  • - $angularCacheFactory.keys()
  • - $angularCacheFactory.keySet()
  • - AngularCache.put(key, value, options)
  • - AngularCache.get(key, options)
  • - AngularCache.remove(key, options)
  • - AngularCache.removeExpired(options)
  • - AngularCache.removeAll()
  • - AngularCache.destroy()
  • - AngularCache.info()
  • - AngularCache.keys()
  • - AngularCache.keySet()
  • - BinaryHeap(weightFunc)
  • - BinaryHeap.push(node)
  • - BinaryHeap.pop()
  • - BinaryHeap.peek()
  • - BinaryHeap.remove(node)
  • - BinaryHeap.removeAll()

Protractor fails when using aggressive delete

Hi,
It caused me some frustration until I finally traced it down. So let me explain:

When writing end-to-end tests using angular's new protractor webdriver the tests fail when you use aggressive delete option. The reason for that is that you use $timeout service to remove caches after timeout as in here.

The way protractor works is that it waits for angular-known services like $http, $q, $timeout and others to complete/resolve before executing next test statement to allow you not to set explicit timeouts in your tests. In other words it will wait for angular to complete before proceeding.

This causes protractor tests to fail with a timeout whenever you put to cache because it waits for your maxAge timeout to resume testing.

Third option to aggressive and passive delete.

I have a situation, where I don't want the cache to immediately delete items that have expired. This is because I need to check if I can update the old item with a request to a third party service, if that third party service rejects my request, I need access to the old cached item and have the option to reset the expiry.

Any ideas on how to achieve that? I see that both passive and aggressive delete both deletes the item when it has been invalidated.

Force cache refresh

Is it possible to actively trigger cache refreshing of a specific $resource request?

don't include the version number in the dist files

When using bower and grunt, if I do a bower update angular-cache and it now installed 1.1.0 instead of 1.0.0 it will break my grunt build, since that was using the path bower_components/angular-cache/dist/angular-cache-1.0.0.js

Since bower is the one in charge of versioning I think you can safely leave the version number out of the filename.

Create a roadmap

Create a roadmap that shows the plan leading up to a 1.0.0 release

Add ability to set "onExpire" function hook in cache configuration.

When an item expires, (or when it is discovered that an item has expired in passive mode), optionally specify a callback function to be executed, which will be passed the key-value pair of the expired item. For example:

aggressive delete mode
var newCache = $angularCacheFactory('newCache', { 
  maxAge: 1000,
  aggressiveDelete: true,
  onExpire: function (key, value) {
    // do something, e.g. retrieve a fresh copy of the expired item from the server
  }
});

newCache.put('item1', 'foo');

// After 1 second, the "onExpire" function is executed.
// In this case, we don't have access to any return value from the "onExpire" callback, so don't rely on that. 
Passive delete mode (which is default)

This has to be handled differently:

var newCache = $angularCacheFactory('newCache', { 
  maxAge: 1000,
  onExpire: function (key, value, done) {
    // do something, e.g. retrieve a fresh copy of the expired item from the server
    done(); // when done, call done() and pass whatever you want into it
  }
});

newCache.put('item1', 'foo');

// ... wait 2 seconds

// Here it is discovered that item1 has expired, so it is deleted by angular-cache.
// Because an "onExpire" function was defined above, it is executed after item1 is deleted.
// Because this cache is in passive delete mode, we can capture a return value from the "onExpire" callback, which we couldn't do in aggressive delete mode.
// We capture the return value by passing in a callback to the get function, which is only executed if the item has expired.
$scope.item1 = newCache.get('item1', function (arg1, arg2, ...) {
  // This callback is the "done" function executed by the "onExpire" callback above.
  // Do something with whatever the "onExpire" callback gave to us.
});

With this feature, your cache can not only clear itself of expired items, but retrieve fresh copies as well (or whatever you want to do when the items expire).

Remove all caches

Hi there!

It might be nice to have an option to clear all caches without calling each one by name.
I think I can wrap cache factory to keep track of all the created caches but maybe there is such an option already?

Clean up docs

  • - Add instructions for installing with bower
  • - Better explain the features of angular-cache over those of $cacheFactory

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.