Class: PDF::Reader::SynchronizedCache

### Home Classes Methods

### In Files

- lib/pdf/reader/synchronized_cache.rb

### Parent

Object

### Methods

- ::new
- #[]
- #[]=

### Files

- MIT-LICENSE
- README.rdoc
- TODO
- mac_expert.txt
- mac_roman.txt
- pdf_doc.txt
- standard.txt
- symbol.txt
- win_ansi.txt
- zapf_dingbats.txt
- glyphlist.txt

### Class/Module Index

Quicksearch

- PDF
- PDF::Reader
- PDF::Reader::Buffer
- PDF::Reader::CidWidths
- PDF::Reader::EncryptedPDFError
- PDF::Reader::Filter
- PDF::Reader::Filter::Ascii85
- PDF::Reader::Filter::AsciiHex
- PDF::Reader::Filter::Depredict
- PDF::Reader::Filter::Flate
- PDF::Reader::Filter::Lzw
- PDF::Reader::Filter::Null
- PDF::Reader::Filter::RunLength
- PDF::Reader::Font
- PDF::Reader::FontDescriptor
- PDF::Reader::FormXObject
- PDF::Reader::InvalidObjectError
- PDF::Reader::MalformedPDFError
- PDF::Reader::ObjectCache
- PDF::Reader::ObjectHash
- PDF::Reader::PageLayout
- PDF::Reader::PageState
- PDF::Reader::PageTextReceiver
- PDF::Reader::Parser
- PDF::Reader::PrintReceiver
- PDF::Reader::Reference
- PDF::Reader::RegisterReceiver
- PDF::Reader::ResourceMethods
- PDF::Reader::StandardSecurityHandler
- PDF::Reader::Stream
- PDF::Reader::SynchronizedCache
- PDF::Reader::TextReceiver
- PDF::Reader::TextRun
- PDF::Reader::TransformationMatrix
- PDF::Reader::UnsupportedFeatureError
- PDF::Reader::WidthCalculator
- PDF::Reader::WidthCalculator::BuiltIn
- PDF::Reader::WidthCalculator::Composite
- PDF::Reader::WidthCalculator::TrueType
- PDF::Reader::WidthCalculator::TypeOneOrThree
- PDF::Reader::WidthCalculator::TypeZero
- PDF::Reader::XRef
- AFM
- AFM::Font

No matching classes.

# PDF::Reader::SynchronizedCache

Throughout the pdf-reader codebase, repeated calculations which can benefit from caching are made In some cases, caching and reusing results can not only save CPU cycles but also greatly reduce memory requirements But at the same time, we don't want to throw away thread safety We have two interchangeable thread-safe cache implementations:

### Public Class Methods

new() click to toggle source

    # File lib/pdf/reader/synchronized_cache.rb, line 20
    def initialize
      @cache = {}
      @mutex = Mutex.new
    end

### Public Instance Methods

[](key) click to toggle source

    # File lib/pdf/reader/synchronized_cache.rb, line 24
    def [](key)
      @mutex.synchronize { @cache[key] }
    end

[]=(key,value) click to toggle source

    # File lib/pdf/reader/synchronized_cache.rb, line 27
    def []=(key,value)
      @mutex.synchronize { @cache[key] = value }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.