UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'B7lKEkMlat4lR59XR0gulhgokXqjGDZe05LQwPSOZG8=' 
WHERE 
  key_id = 'f467f45faeea800b80d3ae833090c937ae960d103142f1bc2300baae8ed1f484' 
  AND (
    token = 'B7lKEkMlat4lR59XR0gulhgokXqjGDZe05LQwPSOZG8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00050