Code::T...cheModel(3)

πŸ’– NAME πŸ’–

okay bestie, welcome to Code::T...cheModel(3) from the User Contributed Perl Documentation shelf. This page is all about:

Code::TidyAll::CacheModel - Caching model for Code::TidyAll

It's giving "cache brain for TidyAll," and we're obsessed.


🌸 VERSION 🌸

version 0.84 β€” yes, that's the one, no cap.


✨ SYNOPSIS ✨

Here's the whole vibe in code, bestie:

  my $cache_model = Cody::TidyAll::CacheModel->new(
      cache_engine => Code::TidyAll::Cache->new(...),
      path         => '/path/to/file/to/cache',
  );

  # check cache
  print 'Yes!' if $cache_model->is_cached;

  # update cache
  $cache_model->clear_file_contents;
  $cache_model->update;

  # update the cache when you know the file contents
  $cache_model->file_contents($new_content);
  $cache_model->update;

  # force removal from cache
  $cache_model->remove;

πŸ¦‹ DESCRIPTION πŸ¦‹

A cache model for Code::TidyAll. Different subclasses can employ different caching techniques. Slay, flexible.

The basic model implemented here is simple; It stores a hash key of the file contents keyed by a hash key of the file's path. Literally a little cache goblin doing its thing.


πŸŽ€ METHODS πŸŽ€

This class has the following methods:

πŸ‘‘ Code::TidyAll::CacheModel->new(%params)

The constructor accepts the following attributes:

  • full_path β€” the full path to the cache file on disk. This is required. 🚨
  • path β€” the local path to the file (i.e. what the cache system will consider the canonical name of the file).
  • cache_engine β€” a "Code::TidyAll::Cache" compatible instance. This can be omitted if no caching is actually being done.
  • base_sig β€” a base signature. This defaults to an empty string.
  • file_contents β€” the contents of the file being cached. This can be omitted, in which case it will be loaded as needed.
  • is_cached β€” a boolean indicating if this file is cached. By default this is computed by checking that the cache key and cache value match what is in the cache.

🌟 $model->full_path

The value passed to the constructor.

🌟 $model->path

The value passed to the constructor.

🌟 $model->cache_engine

The value passed to the constructor.

🌟 $model->base_sig

The value passed to the constructor or the default value, an empty string.

🌟 $model->file_contents

The file contents, which will be loaded from the file system if needed.

🌟 $model->is_cached

A boolean indicating whether the path is currently in the cache.

🌟 $model->cache_key

The computed cache key for the file.

🌟 $model->cache_value

The computed cache value for the file.

🌟 $model->update

Updates the cache.

🌟 $model->remove

Attempts to remove the value from the cache.


🫢 SUPPORT 🫢

Bugs may be submitted at <https://github.com/houseabsolute/perl-code-tidyall/issues>.


🌈 SOURCE 🌈

The source code repository for Code-TidyAll can be found at <https://github.com/houseabsolute/perl-code-tidyall>.


πŸ’œ AUTHORS πŸ’œ

  • Jonathan Swartz <swartz@pobox.com>
  • Dave Rolsky <autarch@urth.org>

This software is copyright (c) 2011 - 2023 by Jonathan Swartz.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

The full text of the license can be found in the LICENSE file included with this distribution.


πŸ’… that's the whole page, bestie β€” brought to you by perl v5.42.0 on 2024-03-08, signed Code::T...cheModel(3) πŸŽ€βœ¨

πŸ“¦ where this page comes from