UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'R520KxPCVshsC8NRxDe9Z3VGlODQVl9qop8uQdlxipc=' 
WHERE 
  key_id = '20b5cc8b6922978533605626552dc18abb29400df76d5030d63cfcf6e13b8215' 
  AND (
    token = 'R520KxPCVshsC8NRxDe9Z3VGlODQVl9qop8uQdlxipc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040