Skip to content

[V5˖] API: Available Methods

Georges.L edited this page Oct 16, 2016 · 2 revisions

Item API

  • Regulars methods
  • getKey() // Return the item identifier (key)
  • get() // The getter, obviously, return your cache object
  • set($value) // The setter, for those who missed it, put 0 meant cache it forever
  • expiresAfter($ttl) // Allow you to extends the lifetime of an entry without altering the value (formerly know as touch())
  • expiresAt($expiration) // Sets the expiration time for this cache item (as a DateTimeInterface object)
  • isHit() // Check if your cache entry exists and is still valid, it is the equivalent of isset()
  • isExpired() // Check if your cache entry is expired
  • getTtl() // Get the remaining Time To Live as an integer
  • getExpirationDate() // Get the expiration date as a Datetime object
  • Atomic methods
  • increment($step = 1) // For integer that we can count on
  • decrement($step = 1) // Redundant joke...
  • append($data) // Append data to a string or an array (push)
  • prepend($data) // Prepend data to a string or an array (unshift)
  • Tags methods
  • addTag($tagName) // Add a tag
  • addTags(array $tagNames) // Add many tags
  • setTags(array $tags) // Set some tags
  • getTags() // Get the tags
  • getTagsAsString($separator = ', ') // Get the data a string separated by $separator
  • removeTag($tagName) // Remove a tag
  • removeTags(array $tagNames) // Remove some tags

ItemPool API

  • Regulars methods
  • getItem($key) // Retrieve an item and returns an empty item if not found
  • getItems(array $keys) // Retrieve one or more item and returns an array of items
  • hasItem($key) // Tests if an item exists
  • deleteItem($key) // Delete an item
  • deleteItems(array $keys) // Delete one or more items
  • save(CacheItemInterface $item) // Persists a cache item immediately
  • saveDeferred(CacheItemInterface $item); // Sets a cache item to be persisted later
  • commit(); // Persists any deferred cache items
  • clear() // Allow you to completely empty the cache and restart from the beginning
  • stats() // Return the cache statistics as an object, useful for checking disk space used by the cache etc.
  • Tags methods
  • getItemsByTag($tagName) // Return items by a tag
  • getItemsByTags(array $tagNames) // Return items by some tags
  • deleteItemsByTag($tagName) // Delete items by a tag
  • deleteItemsByTags(array $tagNames) // Delete items by some tags
  • Atomic methods with tags
    • incrementItemsByTag($tagName, $step = 1) // Increment items by a tag
    • incrementItemsByTags(array $tagNames, $step = 1) // Increment items by some tags
    • decrementItemsByTag($tagName, $step = 1) // Decrement items by a tag
    • decrementItemsByTags(array $tagNames, $step = 1) // Decrement items by some tags
    • appendItemsByTag($tagName, $data) // Append items by a tag
    • appendItemsByTags(array $tagNames, $data) // Append items by some tags
    • prependItemsByTag($tagName, $data) // Prepend items by a tag
    • prependItemsByTags(array $tagNames, $data) // Prepend items by some tags
Clone this wiki locally