UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'fyan1wF0+vMCOAyRAfzmzPuXQhFXoH+GVkHiLMy+ivA=' 
WHERE 
  key_id = 'd7c6e7e13d6144ee33c64571b715087c687f8474f9178510a6cd2e48d7fc0382' 
  AND (
    token = 'fyan1wF0+vMCOAyRAfzmzPuXQhFXoH+GVkHiLMy+ivA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040