UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'AB8C2JEaL5pfELczmahoS0Km8NtHJ5nWFVyoKmXONtM=' 
WHERE 
  key_id = '777457d70bcb057097c7c1edb727b71e88f9da9c980c46fb8a79e4e6e4f33694' 
  AND (
    token = 'AB8C2JEaL5pfELczmahoS0Km8NtHJ5nWFVyoKmXONtM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00047