UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'IGuyya1YzMcPYFebEe0tn4I29J41gYo3YALY5nr4wGI=' 
WHERE 
  key_id = '8cbcc5383832458096719de09c70b30700c67711f96abb0137b9a382261c59a4' 
  AND (
    token = 'IGuyya1YzMcPYFebEe0tn4I29J41gYo3YALY5nr4wGI=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00036